简体   繁体   English

使用不同的程序包名称创建应用程序的“专业版”

[英]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? 如何实现实名重构?

First, select the settings 首先,选择设置 图标 and then 接着

Then uncheck compact empty middle package, then refractor (shift+F6) each package name and make sure it changes in manifest and all over and clean and rebuild the project Also, check this 然后取消选择紧凑空中间包,然后验光仪(Shift + F6),每个包的名称,并确保它改变清单和遍布,干净,而且重建项目,检查

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM