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