简体   繁体   中英

Android project with multiple manifests

I have an android studio project that has different folders being included depending on how the project is being built.

The file structure I am using looks like the following:

src/main/AndroidManifest.xml
        /java
        /res
src/FOO/AndroidManifest.xml
        /java
        /res

All of the configuration is done through gradle:

java.srcDirs += <src/FOO/java>

The issue is that I am not sure how to use the manifest that would be located in the FOO directory in addition to a main manifest.

Can this be done using manifest merging? Or is this not an intended usage? Or does the manifest merger only look for manifests under directory the main manifest is located in?

I believe the manifest merger isn't aware of the manifest in src/FOO/AndroidManifest.xml.

The different paths that you describe should correspond to different build variants (flavour + build type combinations). In each build variant directory you can include a different AndroidManifest.xml file that will be merged with the one in the main folder. New (unknown) entries will simply be appended to the main AndroidManifest. The tricky part comes when you will have "conflicting" entries in the different folders. I would advise you to have a look at the documentation of the manifest merger, which can be found here . It is pretty explanatory, and it also includes a link to the Android Studio's Merged Manifest view tool and how to use it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM