本指南介绍如何解决因重复应用 Airbridge SDK 备份规则和第三方 SDK 备份规则而导致的构建错误。
例如,Airbridge SDK 备份规则和 Appsflyer SDK 备份规则重复应用时可能引发冲突。
Attribute application@fullBackupContent value=(@xml/appsflyer_backup_rules) from [com.appsflyer:af-android-sdk:6.6.1] AndroidManifest.xml:14:18-73
is also present at [io.airbridge:sdk-android:2.14.0] AndroidManifest.xml:27:18-78 value=(@xml/airbridge_auto_backup_rules).
Suggestion: add 'tools:replace="android:fullBackupContent"' to <application> element at AndroidManifest.xml:7:5-13:19 to override.
请创建 src/main/res/xml
文件夹。
请在步骤 1. 创建的 xml 文件夹中创建一个文件(例如:custom_backup_rules.xml
)。
请添加 Airbridge SDK 定义的数据备份规则,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
<!-- Airbridge Backup Rules -->
<exclude domain="sharedpref" path="airbridge-internal" />
<exclude domain="sharedpref" path="airbridge-install" />
<exclude domain="sharedpref" path="airbridge-user-info" />
<exclude domain="sharedpref" path="airbridge-user-alias" />
<exclude domain="sharedpref" path="airbridge-user-attributes" />
<exclude domain="sharedpref" path="airbridge-device-alias" />
<exclude domain="database" path="airbridge.db" />
<!-- Appsflyer Backup Rules -->
<exclude domain="sharedpref" path="appsflyer-data"/>
<!-- your custom rules -->
</full-backup-content>
<manifest
...
xmlns:tools="http://schemas.android.com/tools">
<application
...
android:allowBackup="true"
android:fullBackupContent="@xml/custom_backup_rules"
tools:replace="android:fullBackupContent">
请创建将存储资源文件的 Android 库项目(Assets/Plugins/Android/res.androidlib
)。
请在步骤 1. 创建的 Android 库项目中添加 AndroidManifest.xml
文件,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="custom.android.res"
android:versionCode="1"
android:versionName="1.0">
</manifest>
请在步骤 1. 创建的 Android 库项目中创建 res/xml
文件夹。
请在步骤 2. 创建的 xml 文件夹中创建一个文件(例如:custom_backup_rules.xml
)。
请添加 Airbridge SDK 定义的数据备份规则,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
<!-- Airbridge Backup Rules -->
<exclude domain="sharedpref" path="airbridge-internal" />
<exclude domain="sharedpref" path="airbridge-install" />
<exclude domain="sharedpref" path="airbridge-user-info" />
<exclude domain="sharedpref" path="airbridge-user-alias" />
<exclude domain="sharedpref" path="airbridge-user-attributes" />
<exclude domain="sharedpref" path="airbridge-device-alias" />
<exclude domain="database" path="airbridge.db" />
<!-- Appsflyer Backup Rules -->
<exclude domain="sharedpref" path="appsflyer-data"/>
<!-- your custom rules -->
</full-backup-content>
请在 Android App Manifest 文件(Assets/Plugins/Android/AndroidManifest.xml
)中添加数据备份规则,如下所示:
<manifest
...
xmlns:tools="http://schemas.android.com/tools">
<application
...
android:allowBackup="true"
android:fullBackupContent="@xml/custom_backup_rules"
tools:replace="android:fullBackupContent">
请参阅以下文档:
请在模块目录中创建一个文件(例如:custom_backup_rules.xml
)。
请添加 Airbridge SDK 定义的数据备份规则,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
<!-- Airbridge Backup Rules -->
<exclude domain="sharedpref" path="airbridge-internal" />
<exclude domain="sharedpref" path="airbridge-install" />
<exclude domain="sharedpref" path="airbridge-user-info" />
<exclude domain="sharedpref" path="airbridge-user-alias" />
<exclude domain="sharedpref" path="airbridge-user-attributes" />
<exclude domain="sharedpref" path="airbridge-device-alias" />
<exclude domain="database" path="airbridge.db" />
<!-- Appsflyer Backup Rules -->
<exclude domain="sharedpref" path="appsflyer-data"/>
<!-- your custom rules -->
</full-backup-content>
请使用 Unreal 插件语言(Unreal Plugin Language,UPL)将在步骤 1. 创建的文件复制到 res/xml
文件夹中,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<root xmlns:android="http://schemas.android.com/apk/res/android">
...
<resourceCopies>
<copyFile src="{YOUR_XML_BACKUP_RULES_PATH}" dst="$S(BuildDir)/res/xml/custom_backup_rules.xml" />
...
</resourceCopies>
...
</root>
请导航至 [Unreal Editor]>[Project Settings]>[Platforms - Android
]>[Advanced APK Packaging
]>[Extra Tags for <application> node
],添加以下元素:
android:allowBackup="true"
android:fullBackupContent="@xml/custom_backup_rules"
tools:replace="android:fullBackupContent"
请参阅以下文档:
Was this page helpful?
<manifest
...
xmlns:tools="http://schemas.android.com/tools">
<application
...
android:allowBackup="true"
android:fullBackupContent="@xml/custom_backup_rules"
tools:replace="android:fullBackupContent">
<manifest
...
xmlns:tools="http://schemas.android.com/tools">
<application
...
android:allowBackup="true"
android:fullBackupContent="@xml/custom_backup_rules"
tools:replace="android:fullBackupContent">
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="custom.android.res"
android:versionCode="1"
android:versionName="1.0">
</manifest>
<?xml version="1.0" encoding="utf-8"?>
<root xmlns:android="http://schemas.android.com/apk/res/android">
...
<resourceCopies>
<copyFile src="{YOUR_XML_BACKUP_RULES_PATH}" dst="$S(BuildDir)/res/xml/custom_backup_rules.xml" />
...
</resourceCopies>
...
</root>