Android 多包名,icon
本篇文章主要记录下android 下的同一工程,打包时配置不同的包名,icon,名称等信息.
1: 多包名
首先讲述下如何配置多包名.
在build.gralde的android 标签下添加:
productFlavors{
xiaomi{
applicationId “com.test.usagetest”
}
huawei{
applicationId “com.test.usagetest1”
}
}
此时如果我们运行的话,会出现下面错误:
A problem occurred configuring project ':app'.
> All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com/r/tools/flavorDimensions-missing-error-message.html
解决办法:
defaultConfig添加一行代码:
flavorDimensions “versionCode”
此时编译重新运行即可.
2: 多icon
-
修改manifest.xml
<application android:allowBackup