Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

android

avd

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

like image 844
Jonathan Avatar asked Aug 10 '18 18:08

Jonathan


People also ask

What is parse error in Android?

“Parse Error: There was a problem parsing the package” is one of the oldest yet most common Android errors. It usually pops up when someone fails to install an application on an Android smartphone. Witnessing the Android error simply means the application cannot be installed due to the . apk parser, i.e. parsing issue.

How to fix ‘ parsing error’ in apk file?

If the APK file is Split into App bundles, ‘ Parsing Error ‘, is pretty common. Make sure the File is Not Split APK App Bundle. If it is a bundle then you need to install it using a Split Installer. Google introduced a new way to distribute Android apps called app bundles.

How to fix error code parse error on Android?

How to Fix Problem of Parse Error on Android? Step 1. Download the APK Editor app. Step 2. Now open APK Editor App and click on “Select an Apk File”. Now search for the app which you wish to install. Step 5. Click the app and select the “common edit” option.

Why do I get an in-app installation error when installing APK files?

The Android OS uses these data strings to run and install the apk file. Sometimes due to some issues with the build or due to manipulation of the file error occurs in-app installation. Why there is an Error in Parsing the Package?

Can I still install an app after receiving a parse error?

If you've received a parse error and still want to install the app in question, you will have to identify and fix the root problem. What's the Cause of an Android Parse Error?


Video Answer


3 Answers

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

like image 177
Melquiades Avatar answered Oct 22 '22 00:10

Melquiades


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.

like image 37
Bilal Avatar answered Oct 22 '22 01:10

Bilal


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.

like image 11
TellMeWhy Avatar answered Oct 22 '22 00:10

TellMeWhy