10

When changing files in an extracted APK, I re-zip it, change the extension to .apk, and install like this:

$ adb install CustomAPK.apk 
2831 KB/s (41896599 bytes in 14.450s)
    pkg: /data/local/tmp/CustomAPK.apk
Failure [INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION]

What is this from?

1

3 Answers 3

5

Generate a key and sign the apk: Android Developer Website

Signing Your App Manually

You do not need Android Studio to sign your app. You can sign your app from the command line using standard tools from the Android SDK and the JDK. To sign an app in release mode from the command line:

Generate a private key using keytool. For example:

$ keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000

This example prompts you for passwords for the keystore and key, and to provide the Distinguished Name fields for your key. It then generates the keystore as a file called my-release-key.keystore. The keystore contains a single key, valid for 10000 days. The alias is a name that you will use later when signing your app.

Compile your app in release mode to obtain an unsigned APK. Sign your app with your private key using jarsigner:

$ jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore my_application.apk alias_name

This example prompts you for passwords for the keystore and key. It then modifies the APK in-place to sign it. Note that you can sign an APK multiple times with different keys.

Verify that your APK is signed. For example:

$ jarsigner -verify -verbose -certs my_application.apk

Align the final APK package using zipalign.

$ zipalign -v 4 your_project_name-unaligned.apk your_project_name.apk

zipalign ensures that all uncompressed data starts with a particular byte alignment relative to the start of the file, which reduces the amount of RAM consumed by an app.

4

INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION

for this Uninstall APP and click run button to fix this issue

3
  • Does this answer pertain to Android Studio or a manual ADB install like the original question?
    – Aly
    Nov 7, 2019 at 18:33
  • INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION for Android studio Nov 11, 2019 at 6:33
  • Simple, yet effective solution. Thanks!
    – Romário
    Jan 19, 2020 at 3:30
0

Build the App, and then Run

solved mine

2
  • not relevant, because the question refers to altering the generated APK to rebuild it.
    – htafoya
    Apr 6, 2022 at 16:50
  • 1
    Can't believe this worked. @ht Jul 13, 2022 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.