Change the Android packagename

HI,
I have created a game using cocos2d-x 3.0, and i would like to change Android package name.
Is there any command or tips to do that.?
Thanks.

Hi @yagoub

you can have a look at this link

also focus what he says over here.

Don’t mess up with your project without recording the changes.
if you know how to use GitHub then ok.
you will be able to track changes and can undo it later.

or just write what you’ve changed in pen and paper

also it is advisable to copy your project folder into a different location for later use
if something goes wrong.

if it works… then tag my handle to let me know.

Happy Coding :smile:

You can change the name of your app package in the android manifest.
You only have to change the first couple of lines:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.your.new.app.id"
      android:versionCode="1"
      android:versionName="1.0"
      android:installLocation="auto">
1 Like

@dwd314159265 is exactly right here.

What you call the APK file really doesn’t matter – you could call it game.apk for all Google cares.

@dwd314159265 really… ??

That’s it… !!
we only need to change that one and it will work… ??

are you sure… ??

there are some nuances like the structure of the tags.

If you use fully qualified object names, you can use

com.funtimes.game.mainmenu as your your Java activity namespace/class name and put that into com.ninjas.game_free and com.ninjas.game_paid just by changing the AndroidManifest.xml

If your AndroidManifest says com.ninjas.game_paid and your points to .mainmenu, then you are telling Android that .mainmenu exists in com.ninjas.game_paid.mainmenu

<activity
        android:name=".HeroesOfSteelMainMenu"
        android:configChanges="orientation|keyboardHidden|screenSize|screenLayout"
        android:label="@string/app_name"
        android:screenOrientation="landscape" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

vs

 <activity
        android:name="com.tresebrothers.games.heroesofsteel.HeroesOfSteelMainMenu"
        android:configChanges="orientation|keyboardHidden|screenSize|screenLayout"
        android:label="@string/app_name"
        android:screenOrientation="landscape" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

In the second example I can set

 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.your.new.app.id"

and it will work, uploading to google under com.your.new.app.id but running com.tresebrothers.games.heroesofsteel.HeroesOfSteelMainMenu

1 Like

Thanks , i did it , i changed the package name with eclipse and i changed the AndroidManifest with the new package name, but the problem, when i run the app
with ‘cocos run -p android -j 4’ i see in the terminal:

running: '/XXXXXX/DEV/adt-bundle-mac-x86_64-20140321/sdk/platform-tools/adb uninstall com.companyname.NewName'

Success
running: '/XXXXXXXX/DEV/adt-bundle-mac-x86_64-20140321/sdk/platform-tools/adb install "/XXXXXXXXXXXXXXXXXX/publish/android/OldName-debug.apk"'

6819 KB/s (57414310 bytes in 8.221s)
	pkg: /data/local/tmp/OldName-debug.apk
Success

The Question is : why the the old name still exist ?

Thanks.

where do you see oldname? In the APK filename? that filename is meaningless. you could call it “foobaz” for all Google cares.

The only thing that matters is the package namespace, com.companyname.NewName

1 Like