The APK failed to install. Error: Could not parse error string
AndroidAvdAndroid Problem Overview
Dragging and dropping an Android Package *.APK into an AVD (Android Virtual Device) throws a cryptic error:
The APK failed to install.
Error: Could not parse error string
-
I've tried an AVD with the latest API (28) and one that matches my own phone (Nougat 7.0)
-
The APK is a python Kivy APK built with buildozer
-
I am new to Android development. I don't even know where to begin to debug this. Is there a better log?
-
If I upload the APK to the AVD via the file manager and install it fails as well.
-
HOWEVER, if I upload this same APK to my actual Android Device, IT WORKS! Not only does it install, but it opens and runs my app just fine with no errors
-
Unknown sources are allowed
(int) Android API to use
android.api = 24
(int) Minimum API required
android.minapi = 24
(int) Android SDK version to use
android.sdk = 24
(str) Android NDK version to use
#android.ndk = 9c
Android Solutions
Solution 1 - Android
> HOWEVER, if I upload this same APK to my actual Android Device, IT WORKS! Not only does it install, but it opens and runs my app just fine with no errors
This tells me it might be because your app uses native libraries which don't match the emulator cpu architecture (see this question)
To get a more detailed error message, install your app via terminal:
adb install path_to_your_app/name_of_your_app.apk
You might see this:
Solution 2 - Android
I was facing the same issue. The problem is, if the same application is already installed with the same version on the Emulator then it won't get update/install. it will throw the same error as you are getting it.
Try the following solutions to fix it.
-
Uninstall the old APK from Emulator and then drag & drop the new APK, it would install the application
-
Change the version number from Build.gradle file as suggested by @Chuy47, build the new APK and install it
Hope it helps.
Solution 3 - Android
After spending a rather long time suffering from this problem myself after building an apk using p4a
using the armeabi-v7a
flag, I discovered the problem, as outlined in @Melquiades answer, the default emulator uses x86
architecture, so of course it won't be compatible.
The solution is to build you apk for x86
, which you can do by specifying such in the p4a
creation command using the arch flag - --arch=x86
. You can see the available options here: https://github.com/kivy/python-for-android/blob/master/pythonforandroid/archs.py
Personally, running python3crystax
ndk with any flag other than armeabi-v7a
failed to find the appropriate binaries. Running using python3 and the android ndk likewise failed for all architectures.
If you are using python3
and would like to build for all architectures, you can use buildozer
. Specifiy python3crystax
in the buildozer.spec
requirements, link the ndk directory on the android.ndk_path
line and specify your chosen architecture on the line
# (str) The Android arch to build for, choices: armeabi-v7a, arm64-v8a, x86
android.arch = x86
install python 3.5 following this tutorial: https://tecadmin.net/install-python-3-5-on-ubuntu/. You may need to downgrade or upgrade your cython
version, depending on your current setup. Note that 0.27, 0.27.2 both don't work with Kivy. I found cython 0.25.2 worked for me. You can remove your previous version and install you chosen with:
sudo pip3 install -U --force-reinstall cython=0.25.2
If you're running on Ubuntu of course :)
And there you have it. You would need to create multiple apks for the different architectures by changing the arch
option in your buildozer.spec
and running buildozer android debug
for each architecture. You can still release to the play store as Google has the option to upload multiple apks: https://developer.android.com/google/play/publishing/multiple-apks.
Good luck ;P
EDIT python-for-android commands using SDK 20 / API 26 / NDK 15c / Python 3.7
and SDK 20 / API 24 / NDK 14b / Python 3.7
work. I have not personally tested the latter but more info can be found in this python-for-android post. Having tested the former, I can verify it works but does not support sqlite3
.
Solution 4 - Android
I had to create a new apk with a higher VersionCode than the current installed app.
My simulator had the version 8 and when I was trying to install a new apk with the same version I was getting the error you mention, so the solution was to increase the versionCode and generate a new apk
Do it in the build.gradle (Module: App) file
android {
defaultConfig {
versionCode 9 <---
versionName "1.1.0"
...
}
...
}
Another solution is to uninstall the current app and install the new apk
Solution 5 - Android
You haven't uninstalled the app from emulator or your apk is just not signed
>>*Disclamer - This is to save time , to automatically generate signedApk >>otherwise you know you can get your signed Apk through ... click on Build-> then GenearateSignedApk
It was an issue for me too. But later I found that my running code is not signned with key certificate. You must run signed api to install signed API.
1.Go to File(Alt-F)
2.Go to project Structure [See this box will open][1]
- Here you Click on Module and
- Click on app,
- Click on SigningCofig
- Click on debug Change the signing config as per your released API [1]: https://i.stack.imgur.com/LjRyA.png
feed the details
>SignedKeyCertificate File Path
>password
>keyAlis
>keyAlias password
Solution 6 - Android
FOR FLUTTER DEV
I switched from Android to Flutter, one of my habit before releasing is throwing the apk to emulator to make sure everything is okay. But with Flutter it doesn't work. After searching I found the error is relating to x86 architecture, but why I can debug normally on x86 but cannot install? The answer is Flutter still support x86 for debug but not for release: https://github.com/flutter/flutter/issues/43005
If you force flutter build x86:
build apk -t lib/env/main_stag.dart --flavor stag --target-platform android-arm,android-arm64,android-x64,android-x86
I will throw the error:
Could not find io.flutter:x86_release:1.0.0
In order to double check, just follows these steps:
Step 1:
Try to install your app via terminal:
adb install app_name.apk
You might see this:
adb: failed to install app_name.apk: Failure [INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries
Step 2:
Go to AVD Manager, check if your emulator CPU is x86
Step 3:
Create a new emulator with x86_64, so you can install apk and debug with the same emulator.
Solution 7 - Android
For me, On Android 9 (API 28) emulator system image, disabling Google Play Protect from play store app worked the trick, and i was able to get rid of the parse error.
> To disable Google Play Protect. Open "Play Store" application => tap > on Menu button => select "Play Protect" option => Disable the options > "Scan device for security threats".
Solution 8 - Android
I managed to solve this issue by RENAMING the apk file and ensuring that:
- doesn't have spaces.
- doesn't start by number
Hope it helps you.
Solution 9 - Android
When uninstalling the app from the emulator doesn't fix this, all I need to do is wipe the emulator's data: In the AVD Manager, click the down arrow on the far right for that emulator and select "Wipe Data".
Solution 10 - Android
This worked for me.....
- Open Play Store
- Go to Menu
- Tap Play Protect
- Disable Scan device for security threats
Solution 11 - Android
clear the emulator memory and restart emulator it will work fine.
Solution 12 - Android
Looking at https://stackoverflow.com/questions/46898322/emulator-5554-unauthorized-for-adb-devices I found that you should use Target Google APIs
instead of Google Play
for Android emulator.
Solution 13 - Android
Can you verify the minimum sdk version for that app? And your virtual devices android version
The AVD version must be greater or equal to the minimum sdk version of app
If it is greater try enabling USB debugging
Solution 14 - Android
Doing the following seemed to fix it:
-
Switching to building via kivy virtual machine on virtual box (buildozer doesn't support all build machines)
-
Then commenting out the buildozer SDK settings (reverting to default SDK versions) in
buildozer.spec
(biuldozer doesn't support all SDKs)
Solution 15 - Android
apk failed to install error could not parse error string
the above error may be because:
- Emulator SDK version lower or higher than APK
- Your apk having root check, if device is rooted, it won't install
Good luck.
Solution 16 - Android
If you are trying to install a new api file, ensure that you need to delete the existing app(if any) on the emulator. Deleting the older app and installing the app file worked for me
Solution 17 - Android
Killing Android emulator from task manager, re-opening emulator and running APK worked for me.
Solution 18 - Android
I solved this like;
- Uploaded apk to my server.
- Open apk URL path on the emulator with Chrome.
- Chrome allows access to unknown sources
- And install
My tested application is a react-native application.