简体   繁体   English

在Android Studio中更改软件包名称

[英]Changing package name in Android Studio

I want to duplicate my Android app and give the new copy a different package name. 我想复制我的Android应用并给新副本一个不同的包名称。 When searching around, I saw advice the the following four steps will do the job... 在四处搜寻时,我看到以下四个步骤可以完成工作的建议...

  1. right click on the root folder of your project. 右键单击项目的根文件夹。

  2. Click "Open Module Setting". 点击“打开模块设置”。

  3. Go to the Flavours tab. 转到“风味”选项卡。

  4. Change the applicationID to whatever package name you want. 将applicationID更改为所需的任何软件包名称。 Press OK. 按确定。

So I did that and it changed the package name in the build.gradle but it didn't change it in any of the source files or the androidmanifest.xml file. 因此,我做到了,它更改了build.gradle中的包名称,但没有更改任何源文件或androidmanifest.xml文件中的包名称。

DEAR MR. 敬爱的先生。 FORUM MODERATOR: PLEASE DON'T MARK THIS AS A DUP POST.... Yes this question has been posted here and other places numerous times and it has also been answered numerous times. 论坛主持人:请不要将此标记为重复帖子。...是的,此问题已在此处和其他地方发布了很多次,并且已经得到了多次回答。 But it has never been answered correctly because I tried all of the answers and none of them worked. 但这从来没有正确回答过,因为我尝试了所有答案,但没有一个起作用。

Perhaps the answer is that there is no easy way. 也许答案是没有简单的方法。 I know that Google does not want to make this an easy thing to do as they apparently oppose app branding. 我知道Google不想让这件事变得容易,因为他们显然反对应用品牌推广。

Does anyone know of a sure way? 有谁知道确定的方法吗?

Thanks, 谢谢,

Dean 院长

In your app gradle file, inside android item, you have this : 在您的应用程式gradle档案中,在android项目内,您有:

defaultConfig {
    applicationId "com.you.freeapp"
    minSdkVersion 14
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}

Just change the applicationId to what you want. 只需将applicationId更改为您想要的即可。

But i'm not sure I understood your question, maybe you wanted this (to add in android item) : 但是我不确定我是否理解您的问题,也许您想要这个(添加android项目):

productFlavors {
    free { applicationId 'com.you.freeapp' }
    paid { applicationId 'com.you.paidapp' }
}

This will make 2 "sibling apps" that share a common base but have different id (and so different package name). 这将使2个“同级应用程序”具有相同的基础,但具有不同的ID(以及不同的程序包名称)。

I personnaly used this to make a free test app and a paying complete app that had different package name and assets. 我个人使用它来制作一个具有不同程序包名称和资产的免费测试应用程序和付费完整应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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