Skip to content

Instantly share code, notes, and snippets.

@Noah-Huppert
Last active December 25, 2023 04:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Noah-Huppert/8a9e8187908a3c9cecc483ea30760db6 to your computer and use it in GitHub Desktop.
Save Noah-Huppert/8a9e8187908a3c9cecc483ea30760db6 to your computer and use it in GitHub Desktop.
Patch Android app manifests to bypass install version checks,

Table Of Contents

Overview

If you get a new phone and want to install an app that works on your previous phone but the Play Store won't allow it, there might be a work-around.

As you upgrade your Android operating system apps that you already have installed will usually stay installed. Apps which have been abandoned and not upgraded often still work on the new Android versions. Even if the app's manifest doesn't officially declare the new Android API versions as being supported they often can continue to work. As new Android versions get released eventually they won't allow apps which target older Android API versions to be installed. However, these apps can often still work.

One fix for this is to repack the app to claim that it supports a newer Android API version. Even if it doesn't. This of course runs the risk that the app's internal code doesn't actually support a newer API version. But often if an app still works after an OS upgrade then it would work if you perform this strategy.

See Instructions for details about how to perform this process.

Thanks to ohmi_II on Reddit for detailing some of these steps.

Instructions

  1. Find the app by listing packages:
    platform-tools/adb shell pm list packages
    
    Find the package name, note this for the next step.
    You can also find the package name by going to the play store and getting a share link, the package name with be in the URL.
  2. Then find the path of the APK by running:
    platform-tools/adb shell pm path <PKG>
    
    Note the output path for the next step (Note: The package: part of the path should not be included in the next step)
  3. Then download the APK:
    platform-tools/adb pull <DEVICE PATH> <OUT DIR>
    
  4. Unpack it by running:
    java -jar ./apktool_2.5.0.jar d <APK> -o <OUT DIR>
    
  5. Edit the <OUT DIR>/AndroidManifest.xml
    • Inside the manifest tag add a uses-sdk element:
      <uses-sdk android:minSdkVersion="8"
           android:targetSdkVersion="23"
           android:maxSdkVersion="23" />
      
    • Modify the platformBuildVersionCode attribute of the manifest tag
  6. Run:
    ./build.sh -i <OUT DIR> -o <NEW_APK>
    
  7. Install:
    platform-tools/adb install <NEW_APK>
    
#!/usr/bin/env bash
show_help() {
cat <<EOF
build.sh [-h] -i IN_DIR -o out.apk
OPTIONS
-i IN_DIR Input directory
-o out.apk Output APK file name
EOF
}
arg_in=""
arg_out=""
while getopts "hi:o:" opt; do
case "$opt" in
i) arg_in="$OPTARG" ;;
o) arg_out="$OPTARG" ;;
h)
show_help
exit 0
;;
'?')
echo "Error: unknown option '$opt'" >&2
exit
;;
esac
done
if [[ -z "$arg_in" ]]; then
echo "Error: -i required" >&2
exit 1
fi
if [[ -z "$arg_out" ]]; then
echo "Error: -o required" >&2
exit 1
fi
PATH_RAW_APK="${arg_in}.raw-apk"
PATH_ZIP_ALIGNED="${arg_in}.zip-aligned"
if [[ -z "$BIN_APKTOOL" ]]; then
BIN_APKTOOL="./apktool_2.5.0.jar"
fi
if [[ -z "$BIN_ZIPALIGN" ]]; then
BIN_ZIPALIGN="~/.local/lib/android-sdk/build-tools/30.0.3/zipalign"
fi
if [[ -z "$BIN_APKSIGNER" ]]; then
BIN_APKSIGNER="~/.local/lib/android-sdk/build-tools/30.0.3/apksigner"
fi
set -ex
java -jar "$BIN_APKTOOL" b "$arg_in" -o "$PATH_RAW_APK"
eval "$BIN_ZIPALIGN" -v 4 "$PATH_RAW_APK" "$PATH_ZIP_ALIGNED"
eval "$BIN_APKSIGNER" sign -ks ./store.jks --out "$arg_out" --ks-key-alias manifest_version_change_rsa "$PATH_ZIP_ALIGNED"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment