How can I have different manifest files for the release and debug versions?

后端 未结 3 1841
隐瞒了意图╮
隐瞒了意图╮ 2021-01-11 11:08

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 b

相关标签:
3条回答
  • 2021-01-11 11:54

    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:

    1. Open Build Variants Window
    2. Change from debug to release
    3. Will be visible on Project -> Android -> manifests
    0 讨论(0)
  • 2021-01-11 12:02

    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/.

    0 讨论(0)
  • 2021-01-11 12:03

    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:

    1. The order in which we override with the source sets is probably the most important thing because the merge cascades down the priority chain. If we want all debug builds to have the manifest, then we should put it in the 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
    2. The name of the variant must absolutely match the folder's name. The Build Variants sidebar shows the list of the variant names, as well as the selected full name's variant. Another way to get a comprehensive report of the possible folder locations for the source sets is to run the gradle task at /Tasks/android/sourceSets from the Gradle sidebar on the right.
    3. The Merged Manifest view is essential and probably the most helpful tool to debug what's happening. Look to the bottom of the editor's tab bar when you have any Manifest file open. Switching to this view gives a compiled, colorized report of all manifests merged together along with any errors and suggestions.

    Detailed documentation on this merging is here: https://developer.android.com/studio/build/manifest-merge

    0 讨论(0)
提交回复
热议问题