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 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 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 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.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
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
Next, repeat the process but instead of dots (
.), use slash (
/). So, replace
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:
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 (
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
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
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!
p.s. Huge thanks to @Boban_Stojmenovic for helping me change my app package name <3