Search code examples
androidpythonkivybuildozer

App construction generates error in toolchain.py by unrecognized argument


Versions

Python: 2.7
OS: Linux Lite (Ubuntu)
Kivy: 1.10.1
Cython: 0.22

Buildozer does not proceed with the creation of the App by an error in toolchain.py and arguments --ndk-api 9.

I switched to all cython versions from 0.21 to the latest, but nothing has changed. I went in the android sdk folder and made several updates, however the problem still persists.

the error is: 'toolchain.py: error: unrecognized arguments: --ndk-api 9'

last part of log:

usage: toolchain.py [-h] [--private PRIVATE] --package PACKAGE --name NAME
                    [--numeric-version NUMERIC_VERSION] --version VERSION
                    [--orientation ORIENTATION] [--launcher] [--icon ICON]
                    [--permission PERMISSIONS [PERMISSIONS ...]]
                    [--meta-data META_DATA] [--presplash PRESPLASH]
                    [--presplash-color PRESPLASH_COLOR] [--wakelock]
                    [--window] [--blacklist BLACKLIST] [--whitelist WHITELIST]
                    [--add-jar ADD_JAR] [--add-aar ADD_AAR] [--depend DEPENDS]
                    [--sdk SDK_VERSION] [--minsdk MIN_SDK_VERSION]
                    [--intent-filters INTENT_FILTERS] [--service SERVICES]
                    [--add-source EXTRA_SOURCE_DIRS]
                    [--try-system-python-compile] [--no-compile-pyo] [--sign]
toolchain.py: error: unrecognized arguments: --ndk-api 9
# Command failed: /usr/bin/python -m pythonforandroid.toolchain apk --debug --bootstrap=sdl2 --dist_name myapp --name 'My Application' --version 0.1 --package org.test.myapp --android_api 19 --minsdk 9 --ndk-api 9 --private /home/dev/Modelos/testea/.buildozer/android/app --orientation portrait --window --copy-libs --arch armeabi-v7a --color=always --storage-dir="/home/dev/Modelos/testea/.buildozer/android/platform/build"
# 
# Buildozer failed to execute the last command
# The error might be hidden in the log above this error
# Please read the full log, and search for it before
# raising an issue with buildozer itself.
# In case of a bug report, please add a full log with log_level = 2

would anyone know the reason for this error?


Solution

  • for other people who may have this same problem, I put here everything I did to solve the bug. Ok, first, this was a bug where the buildozer.spec file for some reason did not properly update the p4a files and there was also an error with the version of ndk used. First I downloaded the r17c version of NDK. I went to the /home/dev/.buildozer/android/platform/ path and extract the downloaded file. Then in the path /home/dev/buildozer/buildozer/default.spec I changed the branch used in p4a for the master and it looked like this: # p4a.branch = master

    I have also changed the following lines:

    # (int) Android API to use
    # android.api = 21
    
    # (int) Minimum API required. You will need to set the android.ndk.api to be as low as this value.
    # android.minapi = 21
    
    # (int) Android SDK version to use
    # android.sdk = 20
    
    # (str) Android NDK version to use
    # android.ndk = r17c
    
    # (int) Android NDK API to use (optional). This is the minimum API your app will support.
    # android.ndk_api = 19
    

    Well, that initially did not change anything in the way the construction was being done and it continued to make a mistake. So I went on the path / home / dev / buildozer / buildozer / targets / and in the file android.py I changed lines 17, 18 and 20 thus:

    ANDROID_API = '21' #line 17
    ANDROID_MINAPI = '21' #line 18
    ANDROID_SDK_VERSION = '20'
    ANDROID_NDK_VERSION = '17c' #line 20
    APACHE_ANT_VERSION = '1.9.4'
    

    in this same file, in the TargetAndroid class I changed lines 46 (the old name is python-for-android-new-version) and 47, the class looks like this:

    class TargetAndroid (Target):
        targetname = 'android_old'
        p4a_directory = "python-for-android" #line 46
        p4a_branch = 'master' #line 47
        p4a_apk_cmd = "python build.py"
    

    Ok, in this same path has a file called android_new.py, in the TargetAndroidNew class I changed lines 16 and 17, the class looks like this:

    class TargetAndroidNew (TargetAndroid):
        targetname = 'android'
        p4a_branch = "master" #line 16
        p4a_directory = "python-for-android" #line 17
        p4a_apk_cmd = "apk --debug --bootstrap ="
        extra_p4a_args = ''
    

    Ok, this should already work, but for some reason there is another path with pretty much the same files, so I made the same changes. No path /home/dev/buildozer/build/lib.linux-x86_64-2.7/buildozer/ I changed the default.spec file as I had done previously. And in the path /home/dev/buildozer/build/lib.linux-x86_64-2.7/buildozer/targets/ I've changed the files android.py and android_new.pyin the same way as I previously did. Now the buildozer performs the proper update of p4a and ndk and works correctly.