简体   繁体   中英

Multiple manifests for the application

Can one Android app have multiple manifests? For example, one for the development stage and the other for production.

If so, how can this be implemented?

Use productFlavours in gradle.

productFlavors {
        prdo{
            resValue 'string', 'app_name', 'Sample APP'
            resValue 'string', 'base_url', 'http://sampleapp.com/'
        }
        staging{
            resValue 'string', 'app_name', 'Sample APP Staging'
            resValue 'string', 'base_url', 'http://sampleapp.staging.com/'
        }
}

Your APK file can contain just one AndroidManifest.xml file

When building your app, the Gradle build merges all manifest files into a single manifest file that's packaged into your APK.

Look at from the android official site:

https://developer.android.com/studio/build/manifest-merge

Use source set main and debug and put two AndroidManifest.xml into there. debug/AndroidManifest.xml will be merged for debug builds; it only has changes and/or eg. additional activities (one can also add code into that source set).

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