背景
在4大组件在AndroidManifest中注册的时候,引入的aar本身就已经注册好了,有些跟外部冲突,或者想统一的情况时,就需强制统一配置信息,这时就需要在自己的代码中做相应的处理。
示例
1,application,中统一:android:label,android:allowBackup,android:networkSecurityConfig,android:resizeableActivity,android:theme
<application
android:name="xxx"
android:allowBackup="false"
android:configChanges="locale"
android:hardwareAccelerated="true"
android:icon="xxx"
android:label="xxx"
android:largeHeap="true"
android:networkSecurityConfig="xxx"
android:usesCleartextTraffic="true"
android:requestLegacyExternalStorage="true"
android:resizeableActivity="true"
android:theme="xxx"
tools:replace="android:label,android:allowBackup,android:networkSecurityConfig,android:resizeableActivity,android:theme">
</application>
2,receiver改变exported,如下:
<receiver
android:name="com.igexin.sdk.PushReceiver"
android:exported="true"
tools:replace="android:exported">
</receiver>
3,uses-permission,如下:
<uses-permission android:name="android.permission.BLUETOOTH"
android:maxSdkVersion="30"
tools:replace="android:maxSdkVersion"/>
4,meta-data,如下:
<meta-data
android:name="android.max_aspect"
android:value="2.34"
tools:replace="android:value" />
5,activity,如下:
<activity
android:name="com.alipay.sdk.app.H5PayActivity"
android:configChanges="orientation|keyboardHidden|navigation|screenSize"
android:exported="false"
android:theme="@style/MGNoTransparentTheme"
android:windowSoftInputMode="adjustResize|stateHidden"
tools:remove="android:process"
tools:replace="android:configChanges" />
6,provider,如下:
<provider
android:name="xxx.FileProvider"
android:authorities="${applicationId}.file.provider"
android:exported="false"
android:grantUriPermissions="true"
tools:replace="android:authorities">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/boxing_file_provider"
tools:replace="android:resource" />
</provider>
总结
AndroidManifest中的配置,都可以通过重新注册,用tools:replace来确定要覆盖的项。