Reputation: 45048
Is it possible to have different manifest files for the debug and release versions of my APK in Android Studio?
Normally I don't have need for such a such a thing but in debug mode, my applications run in a different user id and process and this is defined in the manifest. I've attached a diff of what my debug manifest has:
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1,5 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mridang.address"
+ android:sharedUserId="com.mridang.dashclock"
android:versionCode="10"
android:versionName="1.0" >
@@ -14,6 +15,7 @@
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
+ android:process="com.mridang.dashclock"
android:label="@string/application_name"
android:theme="@android:style/Theme.Holo.Light.DarkActionBar" >
I'm losing my mind with stashing the debug manifest file and popping it before building and if two separate manifests were possible, that would be great.
Upvotes: 27
Views: 26559
Reputation: 544
Kotlin Multiplatform (KMP):
Add a folder src/androidDebug
containing AndroidManifest.xml
with the debug-specific config.
If you have some debug-specific activities, Android Studio gives an obscure error when trying to run those: "component activation exception". Apparently the linking to the debug manifest does not work 100%. You can resolve this error by explicitly specifying the link to the manifest in your build.gradle.kts
file:
android {
...
sourceSets {
getByName("debug") {
manifest.srcFile("src/androidDebug/AndroidManifest.xml")
}
}
}
Upvotes: 0
Reputation: 10494
For those of us who have variants in their app and still need to customize the debug manifest for usage in their variants, these following bits of information might help:
src/debug
folder - then all variant's manifests will override this one. If you want to have the debug manifest to apply to only a particular variant then you should put it at src/variantnameDebug/AndroidManifest.xml
Detailed documentation on this merging is here: https://developer.android.com/studio/build/manifest-merge
Upvotes: 8
Reputation: 1850
Yes, it is possible. Use this paths:
Debug Manifest: ../src/debug/AndroidManifest.xml
Release Manifest: ../src/release/AndroidManifest.xml
Show Release Manifest on Android Studio:
Upvotes: 4
Reputation: 12823
Create a "debug" folder under src/ and put it in there: https://github.com/androidfu/Now-Playing/tree/master/app/src
My "release" manifest is in src/main/, but I'm pretty sure if you needed two wholly separate manifest files you could use src/release/ and src/debug/.
Upvotes: 44