69

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

enter image description here

The APK failed to install. Error: Could not parse error string

Jonathan
  • 6,741
  • 7
  • 52
  • 69
  • i am also facing this problem , but this issue is from newly updated oreo versions, I guess its related to security, saying our apps are not verified (the string is related to our package name I guess) and to ensure our devices security they are not installing manually in Android devices - showing security risk by play protect. – karthik Aug 11 '18 at 01:38
  • I was using Nougat though, isn't that before Oreo? And I allow Unknown sources – Jonathan Aug 11 '18 at 05:10

20 Answers20

48

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:

adb: failed to install name_of_your_app.apk: Failure [INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries

Melquiades
  • 8,496
  • 1
  • 31
  • 46
38

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.

  1. Uninstall the old APK from Emulator and then drag & drop the new APK, it would install the application

  2. Change the version number from Build.gradle file as suggested by @Chuy47, build the new APK and install it

Hope it helps.

Bilal
  • 1,034
  • 11
  • 23
11

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.

TellMeWhy
  • 315
  • 3
  • 17
8

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

Chuy47
  • 2,391
  • 1
  • 30
  • 29
8

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
  2. Click on app,
  3. Click on SigningCofig
  4. Click on debug Change the signing config as per your released API feed the details

SignedKeyCertificate File Path

password

keyAlis

keyAlias password

6

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

enter image description here

Step 3:

Create a new emulator with x86_64, so you can install apk and debug with the same emulator.

thanhbinh84
  • 17,876
  • 6
  • 62
  • 69
3

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".

Qasim
  • 5,181
  • 4
  • 30
  • 51
  • Thanks. I was getting mad about why Kivy-Buildozer .apk was being not installed and no error - no reason about that behaviour. – Reaversword Mar 21 '19 at 18:01
3

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".

Gumby The Green
  • 603
  • 7
  • 10
2

I managed to solve this issue by RENAMING the apk file and ensuring that:

  1. doesn't have spaces.
  2. doesn't start by number

Hope it helps you.

1

This worked for me.....

  • Open Play Store
  • Go to Menu
  • Tap Play Protect
  • Disable Scan device for security threats
cHAuHaN
  • 111
  • 1
  • 5
1

clear the emulator memory and restart emulator it will work fine.

Sandeep Duve
  • 131
  • 1
  • 5
1

Looking at emulator-5554 unauthorized for adb devices I found that you should use Target Google APIs instead of Google Play for Android emulator.

CoolMind
  • 26,736
  • 15
  • 188
  • 224
0

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

Eldhopj
  • 2,703
  • 3
  • 20
  • 39
0

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)
Jonathan
  • 6,741
  • 7
  • 52
  • 69
0

apk failed to install error could not parse error string

the above error may be because:

  1. Emulator SDK version lower or higher than APK
  2. Your apk having root check, if device is rooted, it won't install

Good luck.

Vinod Joshi
  • 7,696
  • 1
  • 50
  • 51
0

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

vinny
  • 360
  • 3
  • 10
0

Killing Android emulator from task manager, re-opening emulator and running APK worked for me.

sravs
  • 330
  • 2
  • 14
0

Many solutions has been posted here, and the original problem has probably been solved by now, but I think there is actually one more thing no one encountered/mentioned.

First things first - I don't know what operating system you are working on, but if it is Linux (Mint), like in my case, you could probably give a try to my solution.

More detailed info about system is here:

➜  ~ inxi -Fxzd 
System:
  Kernel: 5.15.0-33-generic x86_64 bits: 64 compiler: N/A 
  Desktop: Cinnamon 5.2.7 Distro: Linux Mint 20.3 Una 
  base: Ubuntu 20.04 focal 
...

If you have the .apk built for arm architecture and you can't change it for whatever reason:

  1. Try installing Android Studio via JetBrains' Toolbox App
  2. When creating new virtual device - use the system image of version 11 or higher.

That's because Android 11 introduced better handling builds for arm architecture on x86 ones. Source: Run ARM apps on the Android Emulator

This should make your emulated device a device (and not unauthorized), what you could see by entering adb devices in the console and thus should let you install your app on the device.

big_OS
  • 381
  • 7
  • 20
-1

I solved this like;

  1. Uploaded apk to my server.
  2. Open apk URL path on the emulator with Chrome.
  3. Chrome allows access to unknown sources
  4. And install

My tested application is a react-native application.

jin jin
  • 193
  • 1
  • 1
  • 7
Fatih Mert Doğancan
  • 1,016
  • 14
  • 21
  • Your server? is it a general solution to every one? There are plenty of apps which require no server at all, and still they can produce issue like this. – Bilal Jan 02 '20 at 10:39
  • As far as I can see, there is no clear or definitive solution to this problem. I tried all the answers did not succeed. Since it is a problem I have to solve; I solved it that way. An answer that I have shared is that friends like me who try all the answers that do not get successful results may solve it with my answer. I wish you'd try it before you judge. I'm sorry. @Bilal – Fatih Mert Doğancan Jan 15 '20 at 17:15
-1

I was facing the same in the emulator.

I solved it just by wiping the data from the emulator.

I hope it helps.