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 应用程序包名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 Gradle 组装时如何更改 Android 应用程序包名称


- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- android 4中的android RadioButton问题 2022-01-01