Troubleshooting

This page can be helpful if you encounter some build issues with DriveKit SDK in your app.

dataExtractionRules property merge issue

If an error message appeared when building your app is something like:

Error: Attribute application@dataExtractionRules value=(@xml/data_extraction_rules) from AndroidManifest.xml:12:9-65 is also present at [com.drivequant.drivekit:drivekit-core:x.x.x] AndroidManifest.xml:13:9-56 value=(@xml/backup_rules). Suggestion: add 'tools:replace="android:dataExtractionRules"' to element at AndroidManifest.xml:9:5-31:19 to override.

It's a backup rules merging issue with DriveKit SDK rules and your app and/or another external library you use.

To resolve this, update your AndroidManifest.xml file:

<application
        android:dataExtractionRules="@xml/merged_data_extraction_rules"
        tools:replace="android:dataExtractionRules"
/>        

Then find the related backup rules of your app or the external library and create the file merged_data_extraction_rules.xml in the src/main/res/xmlfolder:

<?xml version="1.0" encoding="utf-8"?>
<data-extraction-rules>
    <!-- Exclude rules of your app and/or the external libraries  -->
    <cloud-backup>
        <exclude domain="sharedpref" path="DriveKitPreferences.xml" />
        <exclude domain="sharedpref" path="DriveKitEncryptedPreferences.xml" />
        <exclude domain="sharedpref" path="DriveKitBackupPrefs.xml" />
        <include domain="sharedpref" path="DriveKitBackup.xml" />
    </cloud-backup>
    <device-transfer>
        <exclude domain="sharedpref" path="DriveKitPreferences.xml" />
        <exclude domain="sharedpref" path="DriveKitEncryptedPreferences.xml" />
        <exclude domain="sharedpref" path="DriveKitBackupPrefs.xml" />
        <include domain="sharedpref" path="DriveKitBackup.xml" />
    </device-transfer>
</data-extraction-rules>

fullBackupContent property merge issue

If an error message appeared when building your app is something like:

Error: Attribute application@fullBackupContent value=(@xml/app_backup_exclusion) from [com.anotherSdk.library:xxx:x.y.z] AndroidManifest.xml:22:18-76 is also present at [com.drivequant.drivekit:drivekit-core:x.x.x] AndroidManifest.xml:11:9-69 value=(@xml/backup_rules_pre_android_12). Suggestion: add 'tools:replace="android:fullBackupContent"' to element at AndroidManifest.xml:42:3-72:17 to override.

It's a backup rules merging issue with DriveKit SDK rules and your app and/or another external library you use.

To resolve this, update your AndroidManifest.xml file:

<application
        android:fullBackupContent=""
        tools:replace="android:fullBackupContent" 
        (…)
/>

Then find the related backup rules of your app or the external library and create the file merged_backup_rules.xml in the src/main/res/xmlfolder:

merged_backup_rules.xml
<?xml version="1.0" encoding="utf-8"?>
<data-extraction-rules>
	<!-- Exclude rules of your app and/or the external libraries  -->

	<exclude domain="sharedpref" path="DriveKitPreferences.xml" />
	<exclude domain="sharedpref" path="DriveKitEncryptedPreferences.xml" />
	<exclude domain="sharedpref" path="DriveKitBackupPrefs.xml" />
	<include domain="sharedpref" path="DriveKitBackup.xml" />
</data-extraction-rules>

If you have both dataExtractionRules and fullBackupContent merge issues, you have to declare the two attrbutes as follows:

<application
        android:dataExtractionRules="@xml/merged_data_extraction_rules"
        android:fullBackupContent="@xml/merged_backup_rules"
        tools:replace="android:dataExtractionRules, android:fullBackupContent"
        (…)
/>

BackupAgent merge issue

If an error message appeared when building your app looks like:

Manifest merger failed : Attribute application@backupAgent value=(com.yourApp.yourClass) from AndroidManifest.xml:9:9-47
	is also present at [:Core] AndroidManifest.xml:11:9-86 value=(com.drivequant.drivekit.core.backup.DriveKitBackupAgent).
	Suggestion: add 'tools:replace="android:backupAgent"' to <application> element at AndroidManifest.xml:7:5-42:19 to override.

It's because DriveKit SDK is using the BackupAgent to restore some user information when the user has reinstalled the app.

DriveKit is providing two ways to handle the error:

Way 1 - Inherit from DriveKitBackupAgent

The easiest way is to make your BackupAgent class inherits our DriveKitBackupAgent class.

Way 2 - Call DriveKit backup methods

If you cannot inherit from DriveKitBackupAgent class, e.g. when you already inherits from another class, you can still:

  1. Add tools:replace="android:backupAgent in your Manifest as suggested in the error message.

  2. Call DriveKitBackupAgent.onCreate(BackupAgentHelper) in your overriden onCreate() method

  3. Call DriveKitBackupAgent.onRestoreFinished(BackupAgentHelper) in your overriden onRestoreFinished() method

Last updated