A complete guide to changing app package name / custom keystore signing

packagename

#1

I see many users are trying to change their application package name for various reasons, most often because they can’t update previously published application on Play Store. This will be a two-part tutorial on how to change package name and how to sign apk with custom keystore. I will be working on my Mac, but all commands can be used on Windows/Linux too.

To complete this process, you will need the following tools:

Apktool

Apktool is used to decompile apk into (some kind of) source code and to compile (build) decompiled sources back to APK. We’ll need it so we can change package name. It consists of the Java jar file and a wrapper script (used to run that jar file) which is different for each operating system. You can download it here: https://ibotpeaches.github.io/Apktool/install/

Jarsigner

Jarsigner is part of the JDK (Java development kit) and is used to sign APK files with your keystore. You can download it here, as a part of JDK: http://www.oracle.com/technetwork/java/javase/downloads/index.html

Zipalign

Zipalign is used to optimize APK and you absolutely have to optimize it in order to put it on the Play store. Zipalign is part of the Android studio: https://developer.android.com/studio/command-line/zipalign.html

I didn’t want to install whole Android studio so I found standalone version for Mac, I’m not sure if there is such thing for Windows or Linux, but you can always install Android studio and get it.


PART 1 - Changing app package name

The idea is to decompile APK, change package name, folder/file paths in the source and folder structure within the app (because package name, among other things, represents the path to folder where the sources are stored), and compile it back to APK.

First, move your APK to the same folder where your apktool is and run following command in that folder:

./apktool.sh d YOUR_APP.apk

On Windows, you’ll run apktool.bat instead of ./apktool.sh:

apktool.bat d YOUR_APP.apk

After this, you should see folder YOUR_APP created with bunch of files inside.

Now, you need to find a good plain text editor which can open whole folder as a project and do a mass search/replace within that folder. I’m using PHPStorm because I’m mainly PHP developer and I feel comfortable using it, but you can use Brackets, Sublime Text, Notepad++, etc…

Load up YOUR_APP folder in your editor and open AndroidManifest.xml and find package name inside, in my case it was com.thunkable.android.avramyu.playground

Next, find a tool to mass search and replace text within all files in your project and replace com.thunkable.android.avramyu.playground with your new package name. For example, I’m using info.avramovic.playground

Next, repeat the process but instead of dots (.), use slash (/). So, replace com/thunkable/android/avramyu/playground with info/avramovic/playground. Depending on project size this can find and replace several hundred/thousand occurrences of this string.

Now, remember when I said package name represents the folder structure too. You need to reorganize your folders so your package name represents the folder structure, looking from the smali folder. Something like this:

Reorganize APK folders

I’m not sure if it can be seen here, but I’m creating info folder inside smali folder, then moving avramyu (and all its contents) inside it and renaming it to avramovic, so the folders are then smali/info/avramovic/playground, same as my package name. Note that if you’re using com.something.appname as your package name, you’d keep the folders inside smali/com/something/appname

Now simply run following command to compile it back to apk:

./apktool.sh b YOUR_APP -o YOUR_APP_new.apk

Similarly as before, on Windows you’d run:

apktool.bat b YOUR_APP -o YOUR_APP_new.apk

That’s it, now YOUR_APP_new.apk has a new package name (info.avramovic.playground)!



PART 2 - Signing your APK with a custom keystore

There are two reasons that I can think of so you need to sign your APK with a custom keystore. Either you previously published your app which was not built with Thunkable, so it was signed with different keystore and package name, and you can’t publish an update until you sign it with the same keystore, or you did publish it with Thunkable but just wanted to change package name. Anyway, you need a keystore (either old or one downloaded from Thunkable) so please copy it in the same folder as APP.keystore.

Before we start, you need to know two things about your keystore: your keystore password and your keystore alias. You can retrieve your keystore alias if you know the password, but you can’t retrieve a forgotten password :slight_smile:

keytool -v -list -keystore APP.keystore

This would show a bunch of data about your keystore, including any aliases.

If you’re using keystore downloaded from Thunkable, here is the data:

Now, to sign your APK with your keystore simply run the following command:

jarsigner -verbose -tsa http://timestamp.comodoca.com -sigalg SHA1withRSA -digestalg SHA1 -keystore APP.keystore -storepass YOUR_PASSWORD YOUR_APP_new.apk "KEYSTORE_ALIAS"

The command should be same on all operating systems.

Next, you can verify if everything is okay by running following command:

jarsigner -verify -verbose -keystore APP.keystore YOUR_APP_new.apk 

Finally, you need to zipalign the APK so it can be published on Play store:

./zipalign -f -v 4 YOUR_APP_new.apk YOUR_APP_new_zipalign.apk

On Windows, it should be similar, probably just without ./ at the beginning:

zipalign -f -v 4 YOUR_APP_new.apk YOUR_APP_new_zipalign.apk

At last, YOUR_APP_new_zipalign.apk is the file you will upload to Play store. You can safely remove YOUR_APP_new.apk, YOUR_APP.apk and folder YOUR_APP


See, I told you it was easy! :grin:

p.s. Huge thanks to @Boban_Stojmenovic for helping me change my app package name <3


YOUR APP SHOULD CONTAIN PACKAGE NAME COM.THUNKABLE.ANDROID.(uSERNAME).(APP NAME)
Package name issues
Package Name Update (Google Play Store Publishers Only)
Is it possible completely remove option which show "Stop this app." , "About this app" and "settings"?
Package Name And App Update In Play Store
Package Name Problem
Removing screen with app name when the app starts
App package name change
Convert from appybuilder gold
Not able to upload my original app in play store
Rename Package Name .aia
Question about App Signing
App moving between developer profiles
Help with changing package name
Changing package name to update existing app
Package name has been changed "Google Play error"
Update app created with thunkable classic
#2

Package name on Thunkable now is without the word Thunkable.


#3

Thanks, but it doesn’t really mater, the process of changing package name (for whatever reason) is still the same :slight_smile:


#4

Finally, someone takes time and does a good tutorial, well done @Avram

/Boban


#5

Amazing work, thanks @Avram


#6

Just Great. :star_struck::star_struck:


#7

Can somebody help me out? I have to make a PEM file out of a .keystore, but I lack both the skills and the programs. Can someone quickly do this five-min process for me? Thank you in advance!


#8

I know this thread is a little old, but I just want to say thank you so much for creating this tutorial. Without this I was going to have to completely republish my app to the app store, so you really saved me here.

Thank you once again, @Avram!


#9

Thanks for this tutorial. It’s helps me a lot


#10

Nice work. I just created a new project (paid version) of an existing, published app (free version). Does this mean I don’t have to remove the package name from my new app, because of the removal of “Thunkable” from the name?


#11

Is it secure?


#12

image
path name: com.thunkable.android.tezcanorcun.ucipucubirkelime
I tried but could not.


#13

What exactly?

If your new package name is com.whatever.package.name, you should move folder nr 5 (ucipucubirkelime) to smali/com/whatever/package/ucipucubirkelime, then rename it to smali/com/whatever/package/name


#14

I tried but the APK Tool doesn’t work! I need help!


#15

What doesn’t work? What does it say?