[英]Multiple manifests for the application
Can one Android app have multiple manifests?一个 Android 应用程序可以有多个清单吗? For example, one for the development stage and the other for production.
例如,一个用于开发阶段,另一个用于生产。
If so, how can this be implemented?如果是这样,如何实施?
Use productFlavours in gradle.在 gradle 中使用 productFlavors。
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您的 APK 文件只能包含一个 AndroidManifest.xml 文件
When building your app, the Gradle build merges all manifest files into a single manifest file that's packaged into your APK.在构建您的应用程序时,Gradle 构建将所有清单文件合并到打包到您的 APK 中的单个清单文件中。
Look at from the android official site:从android官网看:
https://developer.android.com/studio/build/manifest-merge https://developer.android.com/studio/build/manifest-merge
Use source set main
and debug
and put two AndroidManifest.xml
into there.使用 source set
main
和debug
并将两个AndroidManifest.xml
放入其中。 debug/AndroidManifest.xml
will be merged for debug builds; debug/AndroidManifest.xml
将被合并以进行调试构建; it only has changes and/or eg.它只有变化和/或例如。 additional activities (one can also add code into that source set).
其他活动(也可以将代码添加到该源集中)。
I beleive you want use this -> https://developer.android.com/studio/build/build-variants我相信你想使用这个-> https://developer.android.com/studio/build/build-variants
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.