My project has 3 Manifest files:
flavour/AndroidManifest.xml
flavourDebug/AndroidManifest.xml
flavourRelease/AndroidManifest.xml
Here is flavour/AndroidManifest.xml:
<manifest
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.READ_CONTACTS" />
</manifest>
Here is flavourDebug/AndroidManifest.xml:
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application android:name="com.domain.android.MyApplication"
android:allowBackup="false"
android:label="@string/app_name"
android:logo="@drawable/ic_logo"
android:theme="@style/Theme.CustomActionBarStyle"
android:networkSecurityConfig="@xml/network_security_config"
tools:replace="theme">
// Activity definitions in here
</application>
</manifest>
Here is flavourRelease/AndroidManifest.xml:
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application android:name="com.domain.android.MyApplication"
android:allowBackup="false"
android:label="@string/app_name"
android:logo="@drawable/ic_logo"
android:theme="@style/Theme.CustomActionBarStyle"
tools:replace="theme">
// Activity definitions in here (these are the EXACT SAME as the ones in flavourDebug/AndroidManifest.xml)
</application>
</manifest>
As you can see, the only difference between the Debug and Release Manifests is that the Release one is missing android:networkSecurityConfig
Also, the // Activity definitions in here
part is exactly the same. What I want is to avoid that Activity repetition. Every time we have to change something in an Activity definition (or add a new Activity) we have to do that in 2 Manifest files (Debug and Release).
I had the idea of putting everything inside the main AndroidManifest.xml file. The problem is that I would not be able to add android:networkSecurityConfig="@xml/network_security_config"
only to the debug builds.
In Android layouts, that problem is solved with the <include>
tag. Unfortunately that is not available in the Manifest.
How can I solve this repetition problem?