Skip to content

Instantly share code, notes, and snippets.

@benvium
Created February 20, 2015 16:14
Show Gist options
  • 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
@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?

@NikolayJuly
Copy link

I'm trying to do the same with aab. But changing AndroidManifest.xml is not enough... while upload aab I'm getting error that Version code already used.

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