I am trying to build a kivy app that has these requirements in buildozer.spec:
requirements = python3,kivy,pillow,plyer,scipy,numpy
all Android (SDK/NDK, API) settings are defaulted (commented)
One run w/o specifying NDK gives:
[INFO]: <- directory context /home/joachim/PycharmProjects/CardReader/.buildozer/android/platform/python-for-android
[WARNING]: install_libs called with no libraries to install!
[INFO]: Building lapack for arm64-v8a
[INFO]: -> directory context /home/joachim/PycharmProjects/CardReader/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/other_builds/lapack/arm64-v8a__ndk_target_21/lapack/build
[ERROR]: Build failed: Please set the environment variable 'LEGACY_NDK' to point to a NDK location with gcc/gfortran support (supported NDK version: 'r21e')
When I clean and then set NDK to 21e and run again I get the other error:
[INFO]: Will compile for the following archs: arm64-v8a, armeabi-v7a
[INFO]: Found Android API target in $ANDROIDAPI: 27
[INFO]: Available Android APIs are (27)
[INFO]: Requested API target 27 is available, continuing.
[INFO]: Found NDK dir in $ANDROIDNDK: /home/joachim/.buildozer/android/platform/android-ndk-r21e
[INFO]: Found NDK version 21e
[ERROR]: Build failed: The minimum supported NDK version is 23. You can download it from https://developer.android.com/ndk/downloads/.
[INFO]: Instructions: Please, go to the android NDK page (https://developer.android.com/ndk/downloads/) and download a supported version.
*** The currently recommended NDK version is 23b ***
How can this mismatch be solved? Looking for supported NDK with gcc/gfortran support. Or, what needs to be set for LEGACY_NDK ?
So I've just ran into that problem and found a solution.
The issue was that to build scipy python for android needs an android ndk that was built with fortran support. These appear to be only supported with NDK version 21 and lower and the NDK needs to be specifically built with fortran support. Luckily someone hosts prebuilt versions for that purpose. https://github.com/mzakharo/android-gfortran/releases (Linux only, if you are building the APK from windows you need to build your own NDK toolchain as described in the readme of that project)
Then you have to do the following:
First you need to download the legacy NDK via buildozer
For this modifiy in buildozer.spec
:
#android.ndk = 23b --> android.ndk = 21e
Then Execute
buildozer android debug
When it fails (this is ok since we only ran buildozer to download the r21 NDK):
tar -jxvf gcc-arm-linux-x86_64.tar.bz2
mv arm-linux-androideabi-4.9 ~/.buildozer/android/platform/android-ndk-r21e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64
Note: change ~/.buildozer
to the path where buildozer stores your ndks
Then revert the changes to buildozer.spec
:
android.ndk = 21e --> #android.ndk = 23b
Now you can build and deploy with
export LEGACY_NDK=~/.buildozer/android/platform/android-ndk-r21e
buildozer android debug deploy run
Note: change ~/.buildozer
as described above