Git Product home page Git Product logo

convert-apk's Introduction

Convert .apk files

Prepare them for Android >= 11 (SDK >= 30)

This repository is a set of scripts written to solved an error appearing when trying to install an app with adb:
Failure [-124: Failed parse during installPackageLI: Targeting R+ (version 30 and above) requires the resources.arsc of installed APKs to be stored uncompressed and aligned on a 4-byte boundary]

Or within Android:
There was a problem parsing the package

I originally found the solution thanks to this comment by T Aria on StackOverflow.

Full example at the bottom.

Usage

  • In Windows cmd:
    convert-apk.bat [-t] <impossible_to_install.apk> <converted.apk>
    OR
    uncompress-resources.bat [-t] <impossible_to_install.apk> <uncompressed.apk>
    align-and-sign.bat <uncompressed.apk> <converted.apk>
  • In Bash:
    chmod +x convert-apk.sh
    ./convert-apk.sh [-t] <impossible_to_install.apk> <converted.apk>
    OR
    chmod +x uncompress-resources.sh align-and-sign.sh
    ./uncompress-resources.sh [-t] <impossible_to_install.apk> <uncompressed.apk>
    ./align-and-sign.sh <uncompressed.apk> <converted.apk>
  • In Git Bash:
    ./convert-apk.sh -t <impossible_to_install.apk> <converted.apk>
    OR
    ./uncompress-resources.sh -t <impossible_to_install.apk> <uncompressed.apk>
    ./align-and-sign.sh <uncompressed.apk> <converted.apk>

Installation of converted app

You have three ways of doing this:

  • Install directly the app with adb:
    adb install --no-incremental <converted.apk>
  • Transfer the file with adb then install it manually:
    adb push <converted.apk> /sdcard/Download - will put the file in the Download folder of the internal memory
  • Transfer it from the file explorer and install it manually

Note that the last two will probably make Google Play Protect throw a warning during installation.

Tweaking

You can change several things in the scripts to customize them. The lines where things can be changed are marked in the files.

  • In align-and-sign.bat and align-and-sign.sh:
    • the key path and the key password, to use an already existing one
    • the first letter of "yes" in your language could be different from the ones supported
    • the default minimum SDK version for apksigner can be lowered if you encounter problems while signing the apk (at the cost of "security", see the documentation)

Requirements

  • Android Studio command line tools: zipalign and apksigner must be in your PATH
  • Java: keytool must be in your PATH
  • Specifically on Windows:
    • PowerShell 5 (included by default) or PowerShell 7 (faster)
      OR
    • Git Bash (use -t for uncompress-resources.sh)
      OR
    • WSL
  • Specifically on Linux:
    • zip and unzip commands

Full example

Suppose a example-app.apk that is impossible to install:

  • In Windows cmd:
    git clone https://github.com/mathieures/convert-apk.git
    cd convert-apk
    copy ..\example-app.apk .
    convert-apk.bat example-app.apk new-example-app.apk
  • In Git Bash:
    git clone https://github.com/mathieures/convert-apk.git
    cd convert-apk
    cp ../example-app.apk .
    ./convert-apk.sh -t example-app.apk new-example-app.apk
  • On Linux:
    git clone https://github.com/mathieures/convert-apk.git
    cd convert-apk
    cp ../example-app.apk .
    chmod +x *.sh
    ./convert-apk.sh example-app.apk new-example-app.apk

convert-apk's People

Contributors

mathieures avatar ppawelred avatar joshcancode avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.