iBotPeaches / Apktool

A tool for reverse engineering Android apk files
https://apktool.org/
Apache License 2.0
20.15k stars 3.58k forks source link

"The APK failed to install. Error: Could not parse error string" error installing apk after d and b with no changes #2250

Closed savagejen closed 4 years ago

savagejen commented 4 years ago

Information

  1. Apktool Version (apktool -version) - apktool 2.4.1
  2. Operating System (Mac, Linux, Windows) - I have tried on both OSX catalina and Windows 10
  3. APK From? (Playstore, ROM, Other) - Other (have tried on several apk files, all obtained from different places)

Steps to Reproduce

Basically, just decompile, make no changes, build, and then install.

$ apktool d whatever.apk $ apktool b whatever -o whatever2.apk Then attempt to install whatever2.apk on a fresh emulator session. I get the error "The APK failed to install. Error: Could not parse error string"

Frameworks

If this APK is from an OEM ROM (Samsung, HTC, LG). No.

APK

If this APK can be freely shared, please upload/attach a link to it. I have tried this on several APKs and all had the same problem. One of them can be downloaded here: http://atx2600.org/ctf/

Questions to ask before submission

  1. Have you tried apktool d, apktool b without changing anything? Yes, that is literally my steps to reproduce.
  2. If you are trying to install a modified apk, did you resign it? N/A
  3. Are you using the latest apktool version? Yes.
savagejen commented 4 years ago

Direct link to sample apk in case the CTF task changes for next month: http://atx2600.org/ctf/TacoCon.apk

iBotPeaches commented 4 years ago

When installing the application, ensure you have a tab open running logcat and try and grab the real crash there. It should help bring some more helpful details to help triage this.

savagejen commented 4 years ago

Sure, done. I tried to start/stop the logging quickly. Just started, installed app, clicked on the error, and stopped. Screen shot of error and logcat log attached.

logcat.txt Screen Shot 2019-12-16 at 11 02 51 AM

savagejen commented 4 years ago

Just wanted to leave an update: it looks like for whatever reason, you still have to repackage and sign the apk even though nothing at all was modified. After doing that, it will install and run just fine. Here is the guide to repackaging and resigning: https://mobile-security.gitbook.io/mobile-security-testing-guide/android-testing-guide/0x05c-reverse-engineering-and-tampering#repackaging

Masterpopo commented 4 years ago

I also encounter the same error by dragging and dropping the APK to my emulator, then the same pop message appears. I tried to enable the developer mode on android studio emulator. Then it solves my problem

rypz79 commented 4 years ago

I have the same problem, decompiling building (with or without singing) the APK even without a single change will reproduce this drag installation error. The original APK will install Apktool v2.4.1 on

Name: Pixel_3_XL_Edited_API_30
CPU/ABI: Google APIs Intel Atom (x86_64)
Path: /home/roey/.android/avd/Pixel_3_XL_Edited_API_30.avd
Target: google_apis [Google APIs] (API level 30)
Skin: pixel_3_xl
SD Card: 512 MB
fastboot.chosenSnapshotFile: 
runtime.network.speed: full
hw.accelerometer: yes
hw.device.name: Pixel 3 XL (Edited)
hw.lcd.width: 1440
hw.initialOrientation: Portrait
image.androidVersion.api: 30
tag.id: google_apis
hw.mainKeys: no
hw.camera.front: emulated
avd.ini.displayname: Pixel 3 XL (Edited) API 30
hw.gpu.mode: auto
hw.ramSize: 1536
PlayStore.enabled: false
fastboot.forceColdBoot: no
hw.cpu.ncore: 2
hw.keyboard: yes
hw.sensors.proximity: yes
hw.dPad: no
hw.lcd.height: 2960
vm.heapSize: 256
skin.dynamic: yes
hw.device.manufacturer: User
hw.gps: yes
hw.audioInput: yes
image.sysdir.1: system-images/android-30/google_apis/x86_64/
showDeviceFrame: yes
hw.camera.back: virtualscene
AvdId: Pixel_3_XL_Edited_API_30
hw.lcd.density: 480
hw.arc: false
hw.device.hash2: MD5:392e084813a05089592220caae61637d
fastboot.forceChosenSnapshotBoot: no
fastboot.forceFastBoot: yes
hw.trackBall: no
hw.battery: yes
hw.sdCard: yes
tag.display: Google APIs
runtime.network.latency: none
disk.dataPartition.size: 6442450944
hw.sensors.orientation: yes
avd.ini.encoding: UTF-8
hw.gpu.enabled: yes

Emulator Any suggestions ?

savagejen commented 3 years ago

Any suggestions ?

Did you try the repackage and re-sign steps from the mobile security gitbook I linked to above? $ zipalign -v 4 dist/UnCrackable-Level1.apk ../UnCrackable-Repackaged.apk $ apksigner sign --ks ~/.android/debug.keystore --ks-key-alias signkey UnCrackable-Repackaged.apk Then install it.