使用Android Studio中的一个项目创建多个APK文件 [英] Create multiple apk files with one project build in Android Studio
问题描述
我的Android项目中有两种风格,一种用于测试服务器,另一种用于生产.我将URL存储在字符串资源中,因此我可以根据选择进行编译的方式访问正确的URL.通常,我每天需要为两台服务器创建多个apk文件.
I have two flavors in my Android project, one works with test server and one with production. I store the URL inside a string resource, so I may access the correct URL based on a flavor that I choose for compilation. Usually I need to create multiple apk files during a day, each time for both servers.
每次我运行项目或从构建"菜单构建apk时,是否都可以创建两个apk文件?
Is there a way to create two apk files each time I run my project or build an apk from Build menu?
推荐答案
如果您有这样的事情:
android {
productFlavors {
dev {
applicationId "your.com.android.devel"
buildConfigField 'String', 'HOST', '"http://192.168.1.78"'
}
prod {
applicationId "your.com.android"
buildConfigField 'String', 'HOST', '"http://yourserver.com"'
}
}
}
您只需要在Gradle项目中运行汇编
You only have to run assemble in Gradle projects
您可以找到所有不同的apks build/outputs/apk
And you can find all the different apks build/outputs/apk
希望这次我会有所帮助
这篇关于使用Android Studio中的一个项目创建多个APK文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!