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

独自空忆成欢 提交于 2019-12-06 16:36:04

问题


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


回答1:


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




回答2:


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.




回答3:


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




回答4:


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.




回答5:


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




回答6:


Make sure the application isn't already installed on your Emulator (Android Virtual Device) When dragging your new .apk or release one to the emulator you will get the Error: Could not parse error string.

1) Delete the existing application from the device

2) Drag to install your new .apk




回答7:


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




回答8:


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)



回答9:


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.




回答10:


This worked for me.....

  • Open Play Store
  • Go to Menu
  • Tap Play Protect
  • Disable Scan device for security threats



回答11:


try this : this work for me better.

Step 1 . Clean Project

Step 2 . Rebuild Project

Step 3 . Run App

I hope it helps you.




回答12:


It was an issue for me too. But later I found that my running code is not signned API. You must run signed api to install signed API.

1.Press Alt+F Go to project Structure See this box will open

Click on Module and Change the signing config as per your released API




回答13:


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




回答14:


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.



来源:https://stackoverflow.com/questions/51791960/the-apk-failed-to-install-error-could-not-parse-error-string

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!