使用Gradle组装时如何更改Android应用程序包名称? [英] How to change the Android app package name when assembling with Gradle?
本文介绍了使用Gradle组装时如何更改Android应用程序包名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以使用 Gradle 更改 Android 应用程序的包名称?
Is it possible to change the package name of an Android application using Gradle?
我需要编译同一个应用程序的两个副本,并有一个唯一的包名(所以我可以向市场发布两次).
I need to compile two copies of the same app, having a unique package name (so I can publish to the market twice).
推荐答案
你可以这样做
android {
...
defaultConfig {
minSdkVersion 8
versionCode 10
}
flavorDimensions "flavor1", "flavor2"
productFlavors {
flavor1 {
applicationId "com.example.flavor1"
versionCode 20
}
flavor2 {
applicationId "com.example.flavor2"
minSdkVersion 14
}
}
}
如果您想进行一次性构建,您还可以更改字段 android.defaultConfig.applicationId
.
You can also change the field android.defaultConfig.applicationId
if you want to do one-off builds.
取自:http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Product-Flavor-Configuration
这篇关于使用Gradle组装时如何更改Android应用程序包名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文