Skip to content

Instantly share code, notes, and snippets.

@benvium
Created February 20, 2015 16:14
Show Gist options
  • Star 31 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save benvium/5923d50c30ab7c7df0f3 to your computer and use it in GitHub Desktop.
Save benvium/5923d50c30ab7c7df0f3 to your computer and use it in GitHub Desktop.
How to change the version number on an existing APK without re-building

This requires the latest version of apktool.

apktool d $APK_PATH -o $OUTPUT_FOLDER

# Open the apktool.yml text file
# Alter the versionCode and versionName entries

# now rebuild!
apktool build $OUTPUT_FOLDER 

# next you need to re-sign the apk with the original keystore file
jarsigner -verbose -keystore $KEYSTORE_PATH -storepass $KEYSTORE_PASSWORD -keypass $KEYSTORE_KEY_PASSWORD $APK_PATH $KEYSTORE_KEY_NAME
~/android-sdk/build-tools/21.1.1/zipalign  -v 4 $APK_PATH $APK_OUT_PATH
@benvium
Copy link
Author

benvium commented Feb 20, 2015

This technique is useful if you want to 'roll back' an Android app.

@billyjoker
Copy link

billyjoker commented Feb 22, 2017

Hi' i've followed your steps but i can not get the updated generated apk, i mean, the last step i've got is rebuilding the apk:

C:\Users\APKTOOL>apktool build C:\APKTOOL\updatedversioncode
I: Using Apktool 2.2.2
I: Checking whether sources has changed...
I: Checking whether resources has changed...
I: Building apk file...
I: Copying unknown files/dir...

And no more...

EDIT:
I've figured out that the apk is in /dist folder and in addition i can specify a new output path using -o,--output

@sajidtassu
Copy link

How to download

@KhuramOzi
Copy link

after building Unsigned APK if I try to run on mobile it doesn't install.error popup indicates
"There was a Problem parsing the Package".
any solutions.and when I try to re-sign it shows illegal option -v.

@Pamblam
Copy link

Pamblam commented Jul 31, 2018

@KhumarOzzie

the last two lines are in fact two lines. if you thought they were word wrapped and put them on the same line you get illegal option error.

@AndreiTelteu
Copy link

Works fine !
If you don't have the apktool command, download it here: https://ibotpeaches.github.io/Apktool/install/
And if play store gives you some error like signature not supported you should add this option to the jarsigner command: -sigalg SHA1withRSA -digestalg SHA1
So that command becomes:

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore $KEYSTORE_PATH -storepass $KEYSTORE_PASSWORD -keypass $KEYSTORE_KEY_PASSWORD $APK_PATH $KEYSTORE_KEY_NAME

@acro5piano
Copy link

acro5piano commented Jul 16, 2019

Thank you @AndreiTelteu

We can install apktool using homebrew:

brew install apktool

@KyleSforza
Copy link

How to find keystore file?

@icmacdonald
Copy link

Hello

This is very useful! However when I upload to the playstore I get this error:

This release is not compliant with the Google Play 64-bit requirement.
The following APKs or app bundles are available to 64-bit devices, but they only have 32-bit native code: [17001]
Include 64-bit and 32-bit native code in your app. Use the Android App Bundle publishing format to automatically ensure that each device architecture receives only the native code that it needs. This avoids increasing the overall size of your app

How do I build using the apktool to be 64bit compliant?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment