简体   繁体   中英

Changing package name in Android Studio

I want to duplicate my Android app and give the new copy a different package name. 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. 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.

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.

Does anyone know of a sure way?

Thanks,

Dean

In your app gradle file, inside android item, you have this :

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

Just change the applicationId to what you want.

But i'm not sure I understood your question, maybe you wanted this (to add in android item) :

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).

I personnaly used this to make a free test app and a paying complete app that had different package name and assets.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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