[英]Creating a “pro” version of an app with different package name
I would like to create a "pro" version of my Android app. 我想创建我的Android应用程序的“专业版”。
I have to slightly change the app name, and the package name, and so on. 我必须稍微更改应用程序名称和程序包名称,等等。
I tried the refactor command (renaming com.appname.app into com.appname.pro.app) but I see that nothing changed. 我尝试了重构命令(将com.appname.app重命名为com.appname.pro.app),但我发现没有任何变化。
How to achieve the real name refactoring? 如何实现实名重构?
I assume you're using Gradle
as a build tool. 我假设您正在使用
Gradle
作为构建工具。 You should use productFlavors
to achieve this. 您应该使用
productFlavors
实现此目的。
Here's how : 这是如何做 :
android {
productFlavors {
free {
applicationId "xyz.some.domain.free"
}
pro {
applicationId "xyz.some.domain.pro"
}
}
}
place the above code
inside your app
level build.gradle
file. 将上面的
code
放在您的app
级别的build.gradle
文件中。 To customise it more, read this . 要对其进行更多自定义,请阅读此内容 。
You can then install pro/free version using Gradle
tasks. 然后,您可以使用
Gradle
任务安装专业版/免费版。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.