Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kivy bleak example, didn't find PythonScanCallback #756

Open
pylogger-html opened this issue Feb 4, 2022 · 30 comments
Open

kivy bleak example, didn't find PythonScanCallback #756

pylogger-html opened this issue Feb 4, 2022 · 30 comments

Comments

@pylogger-html
Copy link

pylogger-html commented Feb 4, 2022

  • bleak version: 0.14.2
  • Python version: 3.8.10
  • Operating System: ubuntu 20.04 LTS
  • BlueZ version (bluetoothctl -v) in case of Linux: 5.53

Description

I'm trying to run the Kivy example on an android phone and final apk fails to launch with the error: "Didn't find class com.github.hbldh.bleak.PythonScanCallback". "buildozer android debug" completed successfully without errors.

What I Did

I created a VM with ubuntu 20.04 LTS, made a virtual environment with the following packages:

appdirs==1.4.4
bleak==0.14.2
buildozer==1.2.0
colorama==0.4.4
Cython==0.29.27
dbus-next==0.2.3
distlib==0.3.4
filelock==3.4.2
importlib-metadata==4.10.1
Jinja2==3.0.3
MarkupSafe==2.0.1
pep517==0.6.0
pexpect==4.8.0
pkg_resources==0.0.0
platformdirs==2.4.1
ptyprocess==0.7.0
pytoml==0.1.21
sh==1.14.2
six==1.16.0
toml==0.10.2
virtualenv==20.13.0
zipp==3.7.0

I ran "buildozer android debug" using the included buildozer.spec file (no edits from GIT revision) and the command completed without any errors. Attached is the logcat from running the application on my phone.

# Check configuration tokens
# Ensure build layout
# Check configuration tokens
# Read available permissions from api-versions.xml
# Preparing build
# Check requirements for android
# Run 'dpkg --version'
# Cwd None
Debian 'dpkg' package management program version 1.19.7 (amd64).
This is free software; see the GNU General Public License version 2 or
later for copying conditions. There is NO warranty.
# Search for Git (git)
#  -> found at /usr/bin/git
# Search for Cython (cython)
#  -> found at /home/user/sirens/venv-sirens/bin/cython
# Search for Java compiler (javac)
#  -> found at /usr/lib/jvm/java-13-openjdk-amd64/bin/javac
# Search for Java keytool (keytool)
#  -> found at /usr/lib/jvm/java-13-openjdk-amd64/bin/keytool
# Install platform
# Run 'git config --get remote.origin.url'
# Cwd /home/user/sirens/.buildozer/android/platform/python-for-android
https://github.com/kivy/python-for-android.git
# Run 'git branch -vv'
# Cwd /home/user/sirens/.buildozer/android/platform/python-for-android
* develop 8b173d99 [origin/develop] Update recipe.py (#2544) (#2546)
# Run '/home/user/sirens/venv-sirens/bin/python -m pip install -q  \'appdirs\' \'colorama>=0.3.3\' \'jinja2\' \'six\' \'enum34; python_version<"3.4"\' \'sh>=1.10; sys_platform!="nt"\' \'pep517<0.7.0\' \'toml\''
# Cwd None
# Apache ANT found at /home/user/.buildozer/android/platform/apache-ant-1.9.4
# Android SDK found at /home/user/.buildozer/android/platform/android-sdk
# Recommended android's NDK version by p4a is: 19c
# Android NDK found at /home/user/.buildozer/android/platform/android-ndk-r19c
# Read available permissions from api-versions.xml
# Check application requirements
# Check garden requirements
# Compile platform
# Run '/home/user/sirens/venv-sirens/bin/python -m pythonforandroid.toolchain create --dist_name=bleakdemo --bootstrap=sdl2 --requirements=python3,kivy,bleak,async_to_sync --arch armeabi-v7a --copy-libs --local-recipes /home/bleak/backends/p4android/recipes --color=always --storage-dir="/home/user/sirens/.buildozer/android/platform/build-armeabi-v7a" --ndk-api=21'
# Cwd /home/user/sirens/.buildozer/android/platform/python-for-android
�[1m[INFO]�[0m:    Will compile for the following archs: armeabi-v7a
�[1m[INFO]�[0m:    Found Android API target in $ANDROIDAPI: 27
�[1m[INFO]�[0m:    Available Android APIs are (27)
�[1m[INFO]�[0m:    Requested API target 27 is available, continuing.
�[1m[INFO]�[0m:    Found NDK dir in $ANDROIDNDK: /home/user/.buildozer/android/platform/android-ndk-r19c
�[1m[INFO]�[0m:    Found NDK version 19c
�[1m[INFO]�[0m:    Getting NDK API version (i.e. minimum supported API) from user argument
�[1m[INFO]�[0m:    ccache is missing, the build will not be optimized in the future.
�[1m[INFO]�[0m:    Found the following toolchain versions: ['4.9']
�[1m[INFO]�[0m:    Picking the latest gcc toolchain, here 4.9
�[1m[INFO]�[0m:    Of the existing distributions, the following meet the given requirements:
�[1m[INFO]�[0m:    	�[32m�[1mbleakdemo�[0m: min API 21, includes recipes (�[32mhostpython3, libffi, openssl, sdl2_image, sdl2_mixer, sdl2_ttf, sqlite3, python3, sdl2, setuptools, six, pyjnius, android, kivy, certifi, async_to_sync, bleak�[0m), built for archs (�[34marmeabi-v7a�[0m)
�[1m[INFO]�[0m:    �[1m�[94mbleakdemo has compatible recipes, using this one�[0m
# Run '/home/user/.buildozer/android/platform/android-sdk/platform-tools/adb devices'
# Cwd None
List of devices attached
3057574931593098	device

# Deploy on 3057574931593098
# Run '/home/user/.buildozer/android/platform/android-sdk/platform-tools/adb install -r "/home/user/sirens/bin/bleakdemo-0.1.0-armeabi-v7a-debug.apk"'
# Cwd /home/user/.buildozer/android/platform
Performing Streamed Install
Success
# Application pushed.
# Run on 3057574931593098
# Run '/home/user/.buildozer/android/platform/android-sdk/platform-tools/adb shell am start -n com.github.hbldh.bleakdemo/org.kivy.android.PythonActivity -a org.kivy.android.PythonActivity'
# Cwd /home/user/.buildozer/android/platform
Starting: Intent { act=org.kivy.android.PythonActivity cmp=com.github.hbldh.bleakdemo/org.kivy.android.PythonActivity }
# Application started.
# Run 'dpkg --version'
# Cwd None
Debian 'dpkg' package management program version 1.19.7 (amd64).
This is free software; see the GNU General Public License version 2 or
later for copying conditions. There is NO warranty.
# Search for Git (git)
#  -> found at /usr/bin/git
# Search for Cython (cython)
#  -> found at /home/user/sirens/venv-sirens/bin/cython
# Search for Java compiler (javac)
#  -> found at /usr/lib/jvm/java-13-openjdk-amd64/bin/javac
# Search for Java keytool (keytool)
#  -> found at /usr/lib/jvm/java-13-openjdk-amd64/bin/keytool
# Run '/home/user/.buildozer/android/platform/android-sdk/platform-tools/adb logcat *:S python:D'
# Cwd /home/user/.buildozer/android/platform
--------- beginning of crash
--------- beginning of main
--------- beginning of system
02-04 09:13:26.211 16135 23616 I python  : Initializing Python for Android
02-04 09:13:26.211 16135 23616 I python  : Setting additional env vars from p4a_env_vars.txt
02-04 09:13:26.211 16135 23616 I python  : Changing directory to the one provided by ANDROID_ARGUMENT
02-04 09:13:26.211 16135 23616 I python  : /data/user/0/com.github.hbldh.bleakdemo/files/app
02-04 09:13:26.211 16135 23616 I python  : Preparing to initialize python
02-04 09:13:26.211 16135 23616 I python  : _python_bundle dir exists
02-04 09:13:26.211 16135 23616 I python  : calculated paths to be...
02-04 09:13:26.211 16135 23616 I python  : /data/user/0/com.github.hbldh.bleakdemo/files/app/_python_bundle/stdlib.zip:/data/user/0/com.github.hbldh.bleakdemo/files/app/_python_bundle/modules
02-04 09:13:26.214 16135 23616 I python  : set wchar paths...
02-04 09:13:26.254 16135 23616 I python  : Initialized python
02-04 09:13:26.254 16135 23616 I python  : AND: Init threads
02-04 09:13:26.255 16135 23616 I python  : testing python print redirection
02-04 09:13:26.255 16135 23616 I python  : Android path ['.', '/data/user/0/com.github.hbldh.bleakdemo/files/app/_python_bundle/stdlib.zip', '/data/user/0/com.github.hbldh.bleakdemo/files/app/_python_bundle/modules', '/data/user/0/com.github.hbldh.bleakdemo/files/app/_python_bundle/site-packages']
02-04 09:13:26.256 16135 23616 I python  : os.environ is environ({'PATH': '/sbin:/system/sbin:/product/bin:/apex/com.android.runtime/bin:/system/bin:/system/xbin:/odm/bin:/vendor/bin:/vendor/xbin', 'MOUNT_SYSTEM_OK': 'true', 'ANDROID_BOOTLOGO': '1', 'ANDROID_ROOT': '/system', 'ANDROID_ASSETS': '/system/app', 'ANDROID_DATA': '/data', 'ANDROID_STORAGE': '/storage', 'ANDROID_RUNTIME_ROOT': '/apex/com.android.runtime', 'ANDROID_TZDATA_ROOT': '/apex/com.android.tzdata', 'EXTERNAL_STORAGE': '/sdcard', 'ASEC_MOUNTPOINT': '/mnt/asec', 'BOOTCLASSPATH': '/apex/com.android.runtime/javalib/core-oj.jar:/apex/com.android.runtime/javalib/core-libart.jar:/apex/com.android.runtime/javalib/okhttp.jar:/apex/com.android.runtime/javalib/bouncycastle.jar:/apex/com.android.runtime/javalib/apache-xml.jar:/system/framework/framework.jar:/system/framework/ext.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/system/framework/knoxsdk.jar:/system/framework/knoxanalyticssdk.jar:/system/framework/smartbondingservice.jar:/system/framework/securetimersdk.jar:/system/framework/fipstimakeystore.jar:/system/framework/timakeystore.jar:/system/framework/sec_sdp_sdk.jar:/system/framework/sec_sdp_hidden_sdk.jar:/system/framework/drutils.jar:/system/framework/android.test.base.jar:/system/framework/ucmopensslenginehelper.jar:/system/framework/esecomm.jar:/system/framework/tcmiface.jar:/system/framework/QPerformance.jar:/system/framework/UxPerformance.jar:/apex/com.android.conscrypt/javalib/conscrypt.jar:/apex/com.android.media/javalib/updatable-media.jar', 'DEX2OATBOOTCLASSPATH': '/apex/com.android.runtime/javalib/core-oj.jar:/apex/com.android.runtime/javalib/core-libart.jar:/apex/com.android.runtime/javalib/okhttp.jar:/apex/com.android.runtime/javalib/bouncycastle.jar:/apex/com.android.runtime/javalib/apache-xml.jar:/system/framework/framework.jar:/system/framework/ext.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/system/framework/knoxsdk.jar:/system/framework/knoxanalyticssdk.jar:/system/framework/smartbondingservice.jar:/system/framework/securetimersdk.jar:/system/framework/fipstimakeystore.jar:/system/framework/timakeystore.jar:/system/framework/sec_sdp_sdk.jar:/system/framework/sec_sdp_hidden_sdk.jar:/system/framework/drutils.jar:/system/framework/android.test.base.jar:/system/framework/ucmopensslenginehelper.jar:/system/framework/esecomm.jar:/system/framework/tcmiface.jar:/system/framework/QPerformance.jar:/system/framework/UxPerformance.jar', 'SYSTEMSERVERCLASSPATH': '/system/framework/services.jar:/system/framework/ethernet-service.jar:/system/framework/wifi-service.jar:/system/framework/com.android.location.provider.jar:/system/framework/uibc_java.jar:/system/framework/ssrm.jar', 'DOWNLOAD_CACHE': '/data/cache', 'MC_AUTH_TOKEN_PATH': '/efs/TEE', 'KNOX_STORAGE': '/data/knox/ext_sdcard', 'ENC_EMULATED_STORAGE_TARGET': '/storage/enc_emulated', 'ANDROID_SOCKET_zygote_secondary': '21', 'ANDROID_SOCKET_usap_pool_secondary': '22', 'ANDROID_ENTRYPOINT': 'main.pyc', 'ANDROID_ARGUMENT': '/data/user/0/com.github.hbldh.bleakdemo/files/app', 'ANDROID_APP_PATH': '/data/user/0/com.github.hbldh.bleakdemo/files/app', 'ANDROID_PRIVATE': '/data/user/0/com.github.hbldh.bleakdemo/files', 'ANDROID_UNPACK': '/data/user/0/com.github.hbldh.bleakdemo/files/app', 'PYTHONHOME': '/data/user/0/com.github.hbldh.bleakdemo/files/app', 'PYTHONPATH': '/data/user/0/com.github.hbldh.bleakdemo/files/app:/data/user/0/com.github.hbldh.bleakdemo/files/app/lib', 'PYTHONOPTIMIZE': '2', 'P4A_BOOTSTRAP': 'SDL2', 'PYTHON_NAME': 'python', 'P4A_IS_WINDOWED': 'True', 'P4A_ORIENTATION': 'portrait', 'P4A_NUMERIC_VERSION': 'None', 'P4A_MINSDK': '21', 'LC_CTYPE': 'C.UTF-8'})
02-04 09:13:26.256 16135 23616 I python  : Android kivy bootstrap done. __name__ is __main__
02-04 09:13:26.256 16135 23616 I python  : AND: Ran string
02-04 09:13:26.256 16135 23616 I python  : Run user program, change dir and execute entrypoint
02-04 09:13:26.349 16135 23616 I python  : [WARNING] [Config      ] Older configuration version detected (0 instead of 21)
02-04 09:13:26.350 16135 23616 I python  : [WARNING] [Config      ] Upgrading configuration in progress.
02-04 09:13:26.355 16135 23616 I python  : [INFO   ] [Logger      ] Record log in /data/user/0/com.github.hbldh.bleakdemo/files/app/.kivy/logs/kivy_22-02-04_0.txt
02-04 09:13:26.355 16135 23616 I python  : [INFO   ] [Kivy        ] v2.0.0
02-04 09:13:26.355 16135 23616 I python  : [INFO   ] [Kivy        ] Installed at "/data/user/0/com.github.hbldh.bleakdemo/files/app/_python_bundle/site-packages/kivy/__init__.pyc"
02-04 09:13:26.355 16135 23616 I python  : [INFO   ] [Python      ] v3.8.9 (default, Feb  4 2022, 09:07:38) 
02-04 09:13:26.355 16135 23616 I python  : [Clang 8.0.2 (https://android.googlesource.com/toolchain/clang 40173bab62ec7462
02-04 09:13:26.355 16135 23616 I python  : [INFO   ] [Python      ] Interpreter at ""
02-04 09:13:27.276 16135 23616 I python  : [INFO   ] [Factory     ] 186 symbols loaded
02-04 09:13:27.471 16135 23616 I python  : [INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2 (img_pil, img_ffpyplayer ignored)
02-04 09:13:27.495 16135 23616 I python  : [INFO   ] [Text        ] Provider: sdl2
02-04 09:13:28.263 16135 23616 I python  :  Traceback (most recent call last):
02-04 09:13:28.263 16135 23616 I python  :    File "/home/user/sirens/.buildozer/android/app/main.py", line 14, in <module>
02-04 09:13:28.264 16135 23616 I python  :    File "/home/user/sirens/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/bleakdemo/armeabi-v7a/bleak/__init__.py", line 34, in <module>
02-04 09:13:28.265 16135 23616 I python  :    File "/home/user/sirens/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/bleakdemo/armeabi-v7a/bleak/backends/p4android/scanner.py", line 16, in <module>
02-04 09:13:28.265 16135 23616 I python  :    File "/home/user/sirens/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/bleakdemo/armeabi-v7a/bleak/backends/p4android/defs.py", line 28, in <module>
02-04 09:13:28.272 16135 23616 I python  :    File "/home/user/sirens/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/bleakdemo/armeabi-v7a/jnius/reflect.py", line 229, in autoclass
02-04 09:13:28.272 16135 23616 I python  :    File "jnius/jnius_export_func.pxi", line 26, in jnius.jnius.find_javaclass
02-04 09:13:28.273 16135 23616 I python  :    File "jnius/jnius_utils.pxi", line 91, in jnius.jnius.check_exception
02-04 09:13:28.273 16135 23616 I python  :  jnius.jnius.JavaException: JVM exception occurred: Didn't find class "com.github.hbldh.bleak.PythonScanCallback" on path: DexPathList[[zip file "/data/app/com.github.hbldh.bleakdemo-2S_nGQ7XxNtDTHeUqZZSpQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.github.hbldh.bleakdemo-2S_nGQ7XxNtDTHeUqZZSpQ==/lib/arm, /data/app/com.github.hbldh.bleakdemo-2S_nGQ7XxNtDTHeUqZZSpQ==/base.apk!/lib/armeabi-v7a, /system/lib, /system/product/lib]] java.lang.ClassNotFoundException
02-04 09:13:28.273 16135 23616 I python  : Python for android ended.
02-04 09:14:19.511 16983 24570 I python  : Initializing Python for Android
02-04 09:14:19.511 16983 24570 I python  : Setting additional env vars from p4a_env_vars.txt
02-04 09:14:19.512 16983 24570 I python  : Changing directory to the one provided by ANDROID_ARGUMENT
02-04 09:14:19.512 16983 24570 I python  : /data/user/0/com.github.hbldh.bleakdemo/files/app
02-04 09:14:19.512 16983 24570 I python  : Preparing to initialize python
02-04 09:14:19.512 16983 24570 I python  : _python_bundle dir exists
02-04 09:14:19.512 16983 24570 I python  : calculated paths to be...
02-04 09:14:19.512 16983 24570 I python  : /data/user/0/com.github.hbldh.bleakdemo/files/app/_python_bundle/stdlib.zip:/data/user/0/com.github.hbldh.bleakdemo/files/app/_python_bundle/modules
02-04 09:14:19.515 16983 24570 I python  : set wchar paths...
02-04 09:14:19.555 16983 24570 I python  : Initialized python
02-04 09:14:19.555 16983 24570 I python  : AND: Init threads
02-04 09:14:19.556 16983 24570 I python  : testing python print redirection
02-04 09:14:19.556 16983 24570 I python  : Android path ['.', '/data/user/0/com.github.hbldh.bleakdemo/files/app/_python_bundle/stdlib.zip', '/data/user/0/com.github.hbldh.bleakdemo/files/app/_python_bundle/modules', '/data/user/0/com.github.hbldh.bleakdemo/files/app/_python_bundle/site-packages']
02-04 09:14:19.557 16983 24570 I python  : os.environ is environ({'PATH': '/sbin:/system/sbin:/product/bin:/apex/com.android.runtime/bin:/system/bin:/system/xbin:/odm/bin:/vendor/bin:/vendor/xbin', 'MOUNT_SYSTEM_OK': 'true', 'ANDROID_BOOTLOGO': '1', 'ANDROID_ROOT': '/system', 'ANDROID_ASSETS': '/system/app', 'ANDROID_DATA': '/data', 'ANDROID_STORAGE': '/storage', 'ANDROID_RUNTIME_ROOT': '/apex/com.android.runtime', 'ANDROID_TZDATA_ROOT': '/apex/com.android.tzdata', 'EXTERNAL_STORAGE': '/sdcard', 'ASEC_MOUNTPOINT': '/mnt/asec', 'BOOTCLASSPATH': '/apex/com.android.runtime/javalib/core-oj.jar:/apex/com.android.runtime/javalib/core-libart.jar:/apex/com.android.runtime/javalib/okhttp.jar:/apex/com.android.runtime/javalib/bouncycastle.jar:/apex/com.android.runtime/javalib/apache-xml.jar:/system/framework/framework.jar:/system/framework/ext.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/system/framework/knoxsdk.jar:/system/framework/knoxanalyticssdk.jar:/system/framework/smartbondingservice.jar:/system/framework/securetimersdk.jar:/system/framework/fipstimakeystore.jar:/system/framework/timakeystore.jar:/system/framework/sec_sdp_sdk.jar:/system/framework/sec_sdp_hidden_sdk.jar:/system/framework/drutils.jar:/system/framework/android.test.base.jar:/system/framework/ucmopensslenginehelper.jar:/system/framework/esecomm.jar:/system/framework/tcmiface.jar:/system/framework/QPerformance.jar:/system/framework/UxPerformance.jar:/apex/com.android.conscrypt/javalib/conscrypt.jar:/apex/com.android.media/javalib/updatable-media.jar', 'DEX2OATBOOTCLASSPATH': '/apex/com.android.runtime/javalib/core-oj.jar:/apex/com.android.runtime/javalib/core-libart.jar:/apex/com.android.runtime/javalib/okhttp.jar:/apex/com.android.runtime/javalib/bouncycastle.jar:/apex/com.android.runtime/javalib/apache-xml.jar:/system/framework/framework.jar:/system/framework/ext.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/system/framework/knoxsdk.jar:/system/framework/knoxanalyticssdk.jar:/system/framework/smartbondingservice.jar:/system/framework/securetimersdk.jar:/system/framework/fipstimakeystore.jar:/system/framework/timakeystore.jar:/system/framework/sec_sdp_sdk.jar:/system/framework/sec_sdp_hidden_sdk.jar:/system/framework/drutils.jar:/system/framework/android.test.base.jar:/system/framework/ucmopensslenginehelper.jar:/system/framework/esecomm.jar:/system/framework/tcmiface.jar:/system/framework/QPerformance.jar:/system/framework/UxPerformance.jar', 'SYSTEMSERVERCLASSPATH': '/system/framework/services.jar:/system/framework/ethernet-service.jar:/system/framework/wifi-service.jar:/system/framework/com.android.location.provider.jar:/system/framework/uibc_java.jar:/system/framework/ssrm.jar', 'DOWNLOAD_CACHE': '/data/cache', 'MC_AUTH_TOKEN_PATH': '/efs/TEE', 'KNOX_STORAGE': '/data/knox/ext_sdcard', 'ENC_EMULATED_STORAGE_TARGET': '/storage/enc_emulated', 'ANDROID_SOCKET_zygote_secondary': '21', 'ANDROID_SOCKET_usap_pool_secondary': '22', 'ANDROID_ENTRYPOINT': 'main.pyc', 'ANDROID_ARGUMENT': '/data/user/0/com.github.hbldh.bleakdemo/files/app', 'ANDROID_APP_PATH': '/data/user/0/com.github.hbldh.bleakdemo/files/app', 'ANDROID_PRIVATE': '/data/user/0/com.github.hbldh.bleakdemo/files', 'ANDROID_UNPACK': '/data/user/0/com.github.hbldh.bleakdemo/files/app', 'PYTHONHOME': '/data/user/0/com.github.hbldh.bleakdemo/files/app', 'PYTHONPATH': '/data/user/0/com.github.hbldh.bleakdemo/files/app:/data/user/0/com.github.hbldh.bleakdemo/files/app/lib', 'PYTHONOPTIMIZE': '2', 'P4A_BOOTSTRAP': 'SDL2', 'PYTHON_NAME': 'python', 'P4A_IS_WINDOWED': 'True', 'P4A_ORIENTATION': 'portrait', 'P4A_NUMERIC_VERSION': 'None', 'P4A_MINSDK': '21', 'LC_CTYPE': 'C.UTF-8'})
02-04 09:14:19.557 16983 24570 I python  : Android kivy bootstrap done. __name__ is __main__
02-04 09:14:19.557 16983 24570 I python  : AND: Ran string
02-04 09:14:19.557 16983 24570 I python  : Run user program, change dir and execute entrypoint
02-04 09:14:19.643 16983 24570 I python  : [INFO   ] [Logger      ] Record log in /data/user/0/com.github.hbldh.bleakdemo/files/app/.kivy/logs/kivy_22-02-04_1.txt
02-04 09:14:19.644 16983 24570 I python  : [INFO   ] [Kivy        ] v2.0.0
02-04 09:14:19.644 16983 24570 I python  : [INFO   ] [Kivy        ] Installed at "/data/user/0/com.github.hbldh.bleakdemo/files/app/_python_bundle/site-packages/kivy/__init__.pyc"
02-04 09:14:19.644 16983 24570 I python  : [INFO   ] [Python      ] v3.8.9 (default, Feb  4 2022, 09:07:38) 
02-04 09:14:19.644 16983 24570 I python  : [Clang 8.0.2 (https://android.googlesource.com/toolchain/clang 40173bab62ec7462
02-04 09:14:19.644 16983 24570 I python  : [INFO   ] [Python      ] Interpreter at ""
02-04 09:14:20.539 16983 24570 I python  : [INFO   ] [Factory     ] 186 symbols loaded
02-04 09:14:20.737 16983 24570 I python  : [INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2 (img_pil, img_ffpyplayer ignored)
02-04 09:14:20.760 16983 24570 I python  : [INFO   ] [Text        ] Provider: sdl2
02-04 09:14:21.215 16983 24570 I python  :  Traceback (most recent call last):
02-04 09:14:21.215 16983 24570 I python  :    File "/home/user/sirens/.buildozer/android/app/main.py", line 14, in <module>
02-04 09:14:21.215 16983 24570 I python  :    File "/home/user/sirens/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/bleakdemo/armeabi-v7a/bleak/__init__.py", line 34, in <module>
02-04 09:14:21.216 16983 24570 I python  :    File "/home/user/sirens/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/bleakdemo/armeabi-v7a/bleak/backends/p4android/scanner.py", line 16, in <module>
02-04 09:14:21.216 16983 24570 I python  :    File "/home/user/sirens/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/bleakdemo/armeabi-v7a/bleak/backends/p4android/defs.py", line 28, in <module>
02-04 09:14:21.216 16983 24570 I python  :    File "/home/user/sirens/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/bleakdemo/armeabi-v7a/jnius/reflect.py", line 229, in autoclass
02-04 09:14:21.217 16983 24570 I python  :    File "jnius/jnius_export_func.pxi", line 26, in jnius.jnius.find_javaclass
02-04 09:14:21.217 16983 24570 I python  :    File "jnius/jnius_utils.pxi", line 91, in jnius.jnius.check_exception
02-04 09:14:21.217 16983 24570 I python  :  jnius.jnius.JavaException: JVM exception occurred: Didn't find class "com.github.hbldh.bleak.PythonScanCallback" on path: DexPathList[[zip file "/data/app/com.github.hbldh.bleakdemo-z21-1eW84jd7w4EncN4hEw==/base.apk"],nativeLibraryDirectories=[/data/app/com.github.hbldh.bleakdemo-z21-1eW84jd7w4EncN4hEw==/lib/arm, /data/app/com.github.hbldh.bleakdemo-z21-1eW84jd7w4EncN4hEw==/base.apk!/lib/armeabi-v7a, /system/lib, /system/product/lib]] java.lang.ClassNotFoundException
02-04 09:14:21.217 16983 24570 I python  : Python for android ended.
@pylogger-html
Copy link
Author

After some trial and error, I was able to get this example to run on my Android phone. To do this I had to copy the PythonScanCallback.java & PythonBluetoothGattCallback.java files from Bleak to my local directory and explicitly add them as source files in the buildozer.spec (android.add_src). This worked and the application finally ran.

It would be nice to not have to do that or to have a better way of doing things, but any working solution is better than nothing.

@Lukwrt
Copy link

Lukwrt commented Feb 11, 2022

Had a similar issue that @pylogger-html had. I tried to run the kivy example with the buildozer.spec and the main.py in the develop branch and had an issue with PythonScanCallBack. I'm trying the fix suggested but it's true at first it's a bit destabilizing that the example is not working right away. I'll edit this to tell if the fix worked or not.

@dlech
Copy link
Collaborator

dlech commented Feb 11, 2022

CI tests for the Android build started failing a few months ago, so we disabled them. Something must have changed in the tooling. You could compare https://github.com/hbldh/bleak/runs/4450281250?check_suite_focus=true and https://github.com/hbldh/bleak/runs/4668307926?check_suite_focus=true to see if there is a difference in the installed dependencies. That should provide a clue of where to look for what changed.

@navr32
Copy link

navr32 commented Jul 22, 2022

Hello ! same problem.

07-22 13:12:01.635 17915 18525 I python : jnius.jnius.JavaException: JVM exception occurred: Didn't find class "com.github.hbldh.bleak.PythonScanCallback" on path: DexPathList[[zip file "/data/app/org.test.blueble-1/base.apk"],nativeLibraryDirectories=[/data/app/org.test.blueble-1/lib/arm64, /data/app/org.test.blueble-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64, /system/vendor/lib64]] java.lang.ClassNotFoundException

Someone have better fix ? Have a nice days. many thanks for all the work.

@navr32
Copy link

navr32 commented Jul 24, 2022

After some search i have reinstall and clean my virtualenv , reinstall dependencies cython,pyjnius python for android..and now this build clean.. many thanks ..and i don't know where the error exactly come from. I build the 0.14.3 or the master and this build.

@avzh72
Copy link

avzh72 commented Dec 7, 2022

Hello ! same problem.
"I/python (10027): jnius.jnius.JavaException: JVM exception occurred: Didn't find class "com.github.hbldh.bleak.PythonScanCallback" on path: DexPathList[[zip file "/data/app/com.github.hbldh.bleakdemo-2/base.apk"],nativeLibraryDirectories=[/data/app/com.github.hbldh.bleakdemo-2/lib/arm, /vendor/lib, /system/lib]] java.lang.ClassNotFoundException"
you reinstalled all packages for buildozer, or only virtualenv, cython, pyjnius?

@navr32
Copy link

navr32 commented Dec 7, 2022

Hi ! I think just the package i have tell in previous post.
In my memory buildozer was not the problem..i hope..because this is very long time i have done this..apologized..

@navr32
Copy link

navr32 commented Dec 7, 2022

On which system do you run ? If linux i have detect that for python package support official by the distribution i have to install them by the package manager..and for package not in build support but just alternative package they give errors...
So finally install package from official build binaries distribution ..and install others by python package manager pip or others..and after all was good...

@avzh72
Copy link

avzh72 commented Dec 7, 2022

Thanks. it didn't work for me. The advice above helped me...

After some trial and error, I was able to get this example to run on my Android phone. To do this I had to copy the PythonScanCallback.java & PythonBluetoothGattCallback.java files from Bleak to my local directory and explicitly add them as source files in the buildozer.spec (android.add_src). This worked and the application finally ran.

@navr32
Copy link

navr32 commented Dec 7, 2022

Yes curious thing...perhaps clean all buildozer and reinstall clean ..How do you install buildozer ? Pip or package distrib ?

@avzh72
Copy link

avzh72 commented Dec 8, 2022

pip3 install buildozer
I'll try to install it again. I use virtualbox with lubuntu 20.04

@obzerving
Copy link

So, it's August 2023 and pylogger-html's solution is still the workaround for this issue. Thank you, pylogger-html.

@robgar2001
Copy link
Contributor

@obzerving could you try again using the latest development version of the kivy example? I had a look at the bleak recipe in #1398. This issue might be fixed now. See the readme, since some stuff has changed.

The previous version of the recipe was quite directory dependent. Which might have caused the recipe to not be able to copy the Java files correctly for you.

Let me know if you find anything

Kind regards,

robgar2001

@DemonBhaiii
Copy link

DemonBhaiii commented Feb 15, 2024

hi, i know i am a little late but i have figured it out. this error is coming because the script could not find the jar file. to fix this issue
find download these java files

  1. https://github.com/hbldh/bleak/blob/develop/bleak/backends/p4android/java/com/github/hbldh/bleak/PythonBluetoothGattCallback.java

  2. https://github.com/hbldh/bleak/blob/develop/bleak/backends/p4android/java/com/github/hbldh/bleak/PythonScanCallback.java
    now make some folders in your main app directory
    com/github/hbldh/bleak
    in this bleak folder paste both the files with same name
    now
    compile these java files by using these commands

  3. javac -classpath /home//.buildozer/android/platform/android-sdk/platforms/android-31/android.jar PythonBluetoothGattCallback.java

  4. javac -classpath /home//.buildozer/android/platform/android-sdk/platforms/android-31/android.jar PythonBluetoothGattCallback.java

make sure this is the path where your .buildozer is or you could just use android SDK for it also

now convert them to jar file
open terminal and go to this directory with it
com/github/hbldh/bleak

run this command
jar cf bluetooth_function.jar *.class

now finally in your buildozer.spec file
add this line
android.add_jars = %(source.dir)s/com/github/hbldh/bleak/bluetooth_function.jar

and you will be good to go ;)

@VirajCEO
Copy link

Copy and paste the above links for some reason they are not working when you click them

@dlech
Copy link
Collaborator

dlech commented Feb 20, 2024

Copy and paste the above links for some reason they are not working when you click them

fixed

@ghost
Copy link

ghost commented Jun 24, 2024

hi there

I tried the Demonbhai's solution and just adding the java files using android.add_src But I keep getting the same error

'''06-24 20:31:14.156 15242 16486 I python : Exception in thread Thread-3 (connect_to_device_async):
06-24 20:31:14.156 15242 16486 I python : Traceback (most recent call last):
06-24 20:31:14.156 15242 16486 I python : File "/home/abof/PycharmProjects/mytibai/.buildozer/android/platform/build-arm64-v8a/build/other_builds/python3/arm64-v8a__ndk_target_24/python3/Lib/threading.py", line 1038, in _bootstrap_inner
06-24 20:31:14.157 15242 16486 I python : File "/home/abof/PycharmProjects/mytibai/.buildozer/android/platform/build-arm64-v8a/build/python-installs/mytibai/arm64-v8a/jnius/init.py", line 85, in jnius_thread_hook
06-24 20:31:14.157 15242 16486 I python : File "/home/abof/PycharmProjects/mytibai/.buildozer/android/platform/build-arm64-v8a/build/other_builds/python3/arm64-v8a__ndk_target_24/python3/Lib/threading.py", line 975, in run
06-24 20:31:14.157 15242 16486 I python : File "/home/abof/PycharmProjects/mytibai/.buildozer/android/app/main.py", line 592, in connect_to_device_async
06-24 20:31:14.158 15242 16486 I python : File "/home/abof/PycharmProjects/mytibai/.buildozer/android/platform/build-arm64-v8a/build/python-installs/mytibai/arm64-v8a/bleak/init.py", line 521, in init
06-24 20:31:14.158 15242 16486 I python : File "/home/abof/PycharmProjects/mytibai/.buildozer/android/platform/build-arm64-v8a/build/python-installs/mytibai/arm64-v8a/bleak/backends/client.py", line 255, in get_platform_client_backend_type
06-24 20:31:14.158 15242 16486 I python : File "/home/abof/PycharmProjects/mytibai/.buildozer/android/platform/build-arm64-v8a/build/python-installs/mytibai/arm64-v8a/bleak/backends/p4android/client.py", line 19, in
06-24 20:31:14.158 15242 16486 I python : File "/home/abof/PycharmProjects/mytibai/.buildozer/android/platform/build-arm64-v8a/build/python-installs/mytibai/arm64-v8a/bleak/backends/p4android/defs.py", line 34, in
06-24 20:31:14.158 15242 16486 I python : File "/home/abof/PycharmProjects/mytibai/.buildozer/android/platform/build-arm64-v8a/build/python-installs/mytibai/arm64-v8a/jnius/reflect.py", line 209, in autoclass
06-24 20:31:14.159 15242 16486 I python : File "jnius/jnius_export_func.pxi", line 22, in jnius.jnius.find_javaclass
06-24 20:31:14.159 15242 16486 I python : File "jnius/jnius_utils.pxi", line 79, in jnius.jnius.check_exception
06-24 20:31:14.159 15242 16486 I python : jnius.jnius.JavaException: JVM exception occurred: Didn't find class "com.github.hbldh.bleak.PythonScanCallback" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/system/lib64, /system/system_ext/lib64, /system/lib64, /system/system_ext/lib64]] java.lang.ClassNotFoundException
'''
and I also used pip to uninstall and reinstall the py modules such as bleak, buildozer and pyjnius
and ofc do an appclean whenever I change anything in the the buildozer file.

@ghost
Copy link

ghost commented Jun 27, 2024

Hi abofgames can you show me your project directory so that i could have a clear understanding what exactly is the issue here?

Hi there , here is both ways I used to add the java files
Screenshot from 2024-06-27 13-31-32
and I used this in the buldozer file :
android.add_jars = %(source.dir)s/com/github/hbldh/bleak/bluetooth_function.jar
and this android.add_src = java
and they both gave the same result

@VirajCEO
Copy link

Hi abofgames can you show me the screenshot of your directory in your ide where the jar file is and also share your buildozer.spec file so that i could have better understanding regarding your issue

@ghost
Copy link

ghost commented Jun 27, 2024

image

[app]

# (str) Title of your application
title = tib ai technology

# (str) Package name
package.name = mytibai

# (str) Package domain (needed for android/ios packaging)
package.domain = org.test

# (str) Source code where the main.py live
source.dir = .

# (list) Source files to include (let empty to include all the files)
source.include_exts = py,png,jpg,kv,atlas

# (list) List of inclusions using pattern matching
#source.include_patterns = assets/*,images/*.png

# (list) Source files to exclude (let empty to not exclude anything)
#source.exclude_exts = spec

# (list) List of directory to exclude (let empty to not exclude anything)
#source.exclude_dirs = /tests

# (list) List of exclusions using pattern matching
# Do not prefix with './'
#source.exclude_patterns = license,images/*/*.jpg

# (str) Application versioning (method 1)
version = 0.1

# (str) Application versioning (method 2)
# version.regex = __version__ = ['"](.*)['"]
# version.filename = %(source.dir)s/main.py

# (list) Application requirements
# comma separated e.g. requirements = sqlite3,kivy      materialyoucolor,exceptiongroup,asyncgui,asynckivy,
requirements = python3,
    kivy==2.3.0,
    kivymd,
    mysql.connector,
    numpy,
    pillow,
    android,
    typing_extensions,
    materialyoucolor,
    exceptiongroup,
    asyncgui,
    asynckivy,
    plyer,
    pyjnius,
    Kivy-Garden,
    pygments,
    bleak==0.22.2,
    async_to_sync,
    async-timeout,
    android.permissions

# (str) Custom source folders for requirements
# Sets custom source for any requirements with recipes
# requirements.source.kivy = ../../kivy

# (str) Presplash of the application
#presplash.filename = %(source.dir)s/data/presplash.png

# (str) Icon of the application
#icon.filename = %(source.dir)s/data/icon.png

# (list) Supported orientations
# Valid options are: landscape, portrait, portrait-reverse or landscape-reverse
orientation = portrait

# (list) List of service to declare
#services = NAME:ENTRYPOINT_TO_PY,NAME2:ENTRYPOINT2_TO_PY

#
# OSX Specific
#

#
# author = © Copyright Info

# change the major version of python used by the app
osx.python_version = 3

# Kivy version to use
osx.kivy_version = 1.9.1

#
# Android specific
#

# (bool) Indicate if the application should be fullscreen or not
fullscreen = 0

# (string) Presplash background color (for android toolchain)
# Supported formats are: #RRGGBB #AARRGGBB or one of the following names:
# red, blue, green, black, white, gray, cyan, magenta, yellow, lightgray,
# darkgray, grey, lightgrey, darkgrey, aqua, fuchsia, lime, maroon, navy,
# olive, purple, silver, teal.
#android.presplash_color = #FFFFFF

# (string) Presplash animation using Lottie format.
# see https://lottiefiles.com/ for examples and https://airbnb.design/lottie/
# for general documentation.
# Lottie files can be created using various tools, like Adobe After Effect or Synfig.
#android.presplash_lottie = "path/to/lottie/file.json"

# (str) Adaptive icon of the application (used if Android API level is 26+ at runtime)
#icon.adaptive_foreground.filename = %(source.dir)s/data/icon_fg.png
#icon.adaptive_background.filename = %(source.dir)s/data/icon_bg.png

# (list) Permissions
# (See https://python-for-android.readthedocs.io/en/latest/buildoptions/#build-options-1 for all the supported syntaxes and properties)
android.permissions = android.permission.INTERNET,
    android.permission.WRITE_EXTERNAL_STORAGE ,
    android.permission.READ_EXTERNAL_STORAGE,
    android.permission.BLUETOOTH,
    android.permission.BLUETOOTH_SCAN,
    android.permission.BLUETOOTH_CONNECT,
    android.permission.BLUETOOTH_ADMIN,
    android.permission.ACCESS_FINE_LOCATION,
    android.permission.ACCESS_COARSE_LOCATION,
    android.permission.ACCESS_BACKGROUND_LOCATION

# (list) features (adds uses-feature -tags to manifest)
#android.features = android.hardware.usb.host

# (int) Target Android API, should be as high as possible.
android.api = 33

# (int) Minimum API your APK / AAB will support.
android.minapi = 24

# (int) Android SDK version to use
#android.sdk = 20

# (str) Android NDK version to use
#android.ndk = 23b

# (int) Android NDK API to use. This is the minimum API your app will support, it should usually match android.minapi.
android.ndk_api = 24

# (bool) Use --private data storage (True) or --dir public storage (False)
#android.private_storage = True

# (str) Android NDK directory (if empty, it will be automatically downloaded.)
#android.ndk_path =

# (str) Android SDK directory (if empty, it will be automatically downloaded.)
#android.sdk_path =

# (str) ANT directory (if empty, it will be automatically downloaded.)
#android.ant_path =

# (bool) If True, then skip trying to update the Android sdk
# This can be useful to avoid excess Internet downloads or save time
# when an update is due and you just want to test/build your package
# android.skip_update = False

# (bool) If True, then automatically accept SDK license
# agreements. This is intended for automation only. If set to False,
# the default, you will be shown the license when first running
# buildozer.
# android.accept_sdk_license = False

# (str) Android entry point, default is ok for Kivy-based app
#android.entrypoint = org.kivy.android.PythonActivity

# (str) Full name including package path of the Java class that implements Android Activity
# use that parameter together with android.entrypoint to set custom Java class instead of PythonActivity
#android.activity_class_name = org.kivy.android.PythonActivity

# (str) Extra xml to write directly inside the <manifest> element of AndroidManifest.xml
# use that parameter to provide a filename from where to load your custom XML code
#android.extra_manifest_xml = ./src/android/extra_manifest.xml

# (str) Extra xml to write directly inside the <manifest><application> tag of AndroidManifest.xml
# use that parameter to provide a filename from where to load your custom XML arguments:
#android.extra_manifest_application_arguments = ./src/android/extra_manifest_application_arguments.xml

# (str) Full name including package path of the Java class that implements Python Service
# use that parameter to set custom Java class which extends PythonService
#android.service_class_name = org.kivy.android.PythonService

# (str) Android app theme, default is ok for Kivy-based app
# android.apptheme = "@android:style/Theme.NoTitleBar"

# (list) Pattern to whitelist for the whole project
#android.whitelist =

# (str) Path to a custom whitelist file
#android.whitelist_src =

# (str) Path to a custom blacklist file
#android.blacklist_src =

# (list) List of Java .jar files to add to the libs so that pyjnius can access
# their classes. Don't add jars that you do not need, since extra jars can slow
# down the build process. Allows wildcards matching, for example:
# OUYA-ODK/libs/*.jar
#android.add_jars = foo.jar,bar.jar,path/to/more/*.jar
#android.add_jars = %(source.dir)s/com/github/hbldh/bleak/bluetooth_function.jar

# (list) List of Java files to add to the android project (can be java or a
# directory containing the files)
#android.add_src =
android.add_src = java

# (list) Android AAR archives to add
#android.add_aars =


# (list) Put these files or directories in the apk assets directory.
# Either form may be used, and assets need not be in 'source.include_exts'.
# 1) android.add_assets = source_asset_relative_path
# 2) android.add_assets = source_asset_path:destination_asset_relative_path
#android.add_assets =

# (list) Put these files or directories in the apk res directory.
# The option may be used in three ways, the value may contain one or zero ':'
# Some examples:
# 1) A file to add to resources, legal resource names contain ['a-z','0-9','_']
# android.add_resources = my_icons/all-inclusive.png:drawable/all_inclusive.png
# 2) A directory, here  'legal_icons' must contain resources of one kind
# android.add_resources = legal_icons:drawable
# 3) A directory, here 'legal_resources' must contain one or more directories, 
# each of a resource kind:  drawable, xml, etc...
# android.add_resources = legal_resources
#android.add_resources =

# (list) Gradle dependencies to add
#android.gradle_dependencies =

# (bool) Enable AndroidX support. Enable when 'android.gradle_dependencies'
# contains an 'androidx' package, or any package from Kotlin source.
# android.enable_androidx requires android.api >= 28
#android.enable_androidx = True

# (list) add java compile options
# this can for example be necessary when importing certain java libraries using the 'android.gradle_dependencies' option
# see https://developer.android.com/studio/write/java8-support for further information
# android.add_compile_options = "sourceCompatibility = 1.8", "targetCompatibility = 1.8"

# (list) Gradle repositories to add {can be necessary for some android.gradle_dependencies}
# please enclose in double quotes 
# e.g. android.gradle_repositories = "maven { url 'https://kotlin.bintray.com/ktor' }"
#android.add_gradle_repositories =

# (list) packaging options to add 
# see https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.PackagingOptions.html
# can be necessary to solve conflicts in gradle_dependencies
# please enclose in double quotes 
# e.g. android.add_packaging_options = "exclude 'META-INF/common.kotlin_module'", "exclude 'META-INF/*.kotlin_module'"
#android.add_packaging_options =

# (list) Java classes to add as activities to the manifest.
#android.add_activities = com.example.ExampleActivity

# (str) OUYA Console category. Should be one of GAME or APP
# If you leave this blank, OUYA support will not be enabled
#android.ouya.category = GAME

# (str) Filename of OUYA Console icon. It must be a 732x412 png image.
#android.ouya.icon.filename = %(source.dir)s/data/ouya_icon.png

# (str) XML file to include as an intent filters in <activity> tag
#android.manifest.intent_filters =

# (list) Copy these files to src/main/res/xml/ (used for example with intent-filters)
#android.res_xml = PATH_TO_FILE,

# (str) launchMode to set for the main activity
#android.manifest.launch_mode = standard

# (str) screenOrientation to set for the main activity.
# Valid values can be found at https://developer.android.com/guide/topics/manifest/activity-element
#android.manifest.orientation = fullSensor

# (list) Android additional libraries to copy into libs/armeabi
#android.add_libs_armeabi = libs/android/*.so
#android.add_libs_armeabi_v7a = libs/android-v7/*.so
#android.add_libs_arm64_v8a = libs/android-v8/*.so
#android.add_libs_x86 = libs/android-x86/*.so
#android.add_libs_mips = libs/android-mips/*.so

# (bool) Indicate whether the screen should stay on
# Don't forget to add the WAKE_LOCK permission if you set this to True
#android.wakelock = False

# (list) Android application meta-data to set (key=value format)
#android.meta_data =

# (list) Android library project to add (will be added in the
# project.properties automatically.)
#android.library_references =

# (list) Android shared libraries which will be added to AndroidManifest.xml using <uses-library> tag
#android.uses_library =

# (str) Android logcat filters to use
android.logcat_filters = *:S python:D

# (bool) Android logcat only display log for activity's pid
#android.logcat_pid_only = False

# (str) Android additional adb arguments
#android.adb_args = -H host.docker.internal

# (bool) Copy library instead of making a libpymodules.so
#android.copy_libs = 1

# (list) The Android archs to build for, choices: armeabi-v7a, arm64-v8a, x86, x86_64
# In past, was `android.arch` as we weren't supporting builds for multiple archs at the same time.
android.archs = arm64-v8a

# (int) overrides automatic versionCode computation (used in build.gradle)
# this is not the same as app version and should only be edited if you know what you're doing
# android.numeric_version = 1

# (bool) enables Android auto backup feature (Android API >=23)
android.allow_backup = True

# (str) XML file for custom backup rules (see official auto backup documentation)
# android.backup_rules =

# (str) If you need to insert variables into your AndroidManifest.xml file,
# you can do so with the manifestPlaceholders property.
# This property takes a map of key-value pairs. (via a string)
# Usage example : android.manifest_placeholders = [myCustomUrl:\"org.kivy.customurl\"]
# android.manifest_placeholders = [:]

# (bool) Skip byte compile for .py files
# android.no-byte-compile-python = False

# (str) The format used to package the app for release mode (aab or apk or aar).
# android.release_artifact = aab

# (str) The format used to package the app for debug mode (apk or aar).
# android.debug_artifact = apk

#
# Python for android (p4a) specific
#

# (str) python-for-android URL to use for checkout
#p4a.url =

# (str) python-for-android fork to use in case if p4a.url is not specified, defaults to upstream (kivy)
#p4a.fork = kivy

# (str) python-for-android branch to use, defaults to master
#p4a.branch = master
#p4a.branch = develop

# (str) python-for-android specific commit to use, defaults to HEAD, must be within p4a.branch
#p4a.commit = HEAD

# (str) python-for-android git clone directory (if empty, it will be automatically cloned from github)
#p4a.source_dir =

# (str) The directory in which python-for-android should look for your own build recipes (if any)
#p4a.local_recipes =
p4a.local_recipes = ../../../../p4a-recipes



# (str) Filename to the hook for p4a
#p4a.hook =

# (str) Bootstrap to use for android builds
# p4a.bootstrap = sdl2

# (int) port number to specify an explicit --port= p4a argument (eg for bootstrap flask)
#p4a.port =

# Control passing the --use-setup-py vs --ignore-setup-py to p4a
# "in the future" --use-setup-py is going to be the default behaviour in p4a, right now it is not
# Setting this to false will pass --ignore-setup-py, true will pass --use-setup-py
# NOTE: this is general setuptools integration, having pyproject.toml is enough, no need to generate
# setup.py if you're using Poetry, but you need to add "toml" to source.include_exts.
#p4a.setup_py = false

# (str) extra command line arguments to pass when invoking pythonforandroid.toolchain
#p4a.extra_args =



#
# iOS specific
#

# (str) Path to a custom kivy-ios folder
#ios.kivy_ios_dir = ../kivy-ios
# Alternately, specify the URL and branch of a git checkout:
ios.kivy_ios_url = https://github.com/kivy/kivy-ios
ios.kivy_ios_branch = master

# Another platform dependency: ios-deploy
# Uncomment to use a custom checkout
#ios.ios_deploy_dir = ../ios_deploy
# Or specify URL and branch
ios.ios_deploy_url = https://github.com/phonegap/ios-deploy
ios.ios_deploy_branch = 1.10.0

# (bool) Whether or not to sign the code
ios.codesign.allowed = false

# (str) Name of the certificate to use for signing the debug version
# Get a list of available identities: buildozer ios list_identities
#ios.codesign.debug = "iPhone Developer: <lastname> <firstname> (<hexstring>)"

# (str) The development team to use for signing the debug version
#ios.codesign.development_team.debug = <hexstring>

# (str) Name of the certificate to use for signing the release version
#ios.codesign.release = %(ios.codesign.debug)s

# (str) The development team to use for signing the release version
#ios.codesign.development_team.release = <hexstring>

# (str) URL pointing to .ipa file to be installed
# This option should be defined along with `display_image_url` and `full_size_image_url` options.
#ios.manifest.app_url =

# (str) URL pointing to an icon (57x57px) to be displayed during download
# This option should be defined along with `app_url` and `full_size_image_url` options.
#ios.manifest.display_image_url =

# (str) URL pointing to a large icon (512x512px) to be used by iTunes
# This option should be defined along with `app_url` and `display_image_url` options.
#ios.manifest.full_size_image_url =


[buildozer]

# (int) Log level (0 = error only, 1 = info, 2 = debug (with command output))
log_level = 2

# (int) Display warning if buildozer is run as root (0 = False, 1 = True)
warn_on_root = 1

# (str) Path to build artifact storage, absolute or relative to spec file
# build_dir = ./.buildozer

# (str) Path to build output (i.e. .apk, .aab, .ipa) storage
# bin_dir = ./bin

#    -----------------------------------------------------------------------------
#    List as sections
#
#    You can define all the "list" as [section:key].
#    Each line will be considered as a option to the list.
#    Let's take [app] / source.exclude_patterns.
#    Instead of doing:
#
#[app]
#source.exclude_patterns = license,data/audio/*.wav,data/images/original/*
#
#    This can be translated into:
#
#[app:source.exclude_patterns]
#license
#data/audio/*.wav
#data/images/original/*
#


#    -----------------------------------------------------------------------------
#    Profiles
#
#    You can extend section / key with a profile
#    For example, you want to deploy a demo version of your application without
#    HD content. You could first change the title to add "(demo)" in the name
#    and extend the excluded directories to remove the HD content.
#
#[app@demo]
#title = My Application (demo)
#
#[app:source.exclude_patterns@demo]
#images/hd/*
#
#    Then, invoke the command line with the "demo" profile:
#
#buildozer --profile demo android debug

@VirajCEO
Copy link

where is your main.py file? here in the screenshot of the directory you shared? is this your source directory?

@ghost
Copy link

ghost commented Jun 27, 2024

here is a screenshot of the whole directory
image

@VirajCEO
Copy link

i see try moving the app and all it's contents in a seperate directory make a new directory myApp or whatever you want to name and then in the buildozer.spec file change this line to

source.dir = .
to
source.dir = ./myApp

@ghost
Copy link

ghost commented Jun 27, 2024

here I did what what you told me in a different env I was testing in :
image

setting source.dir to ./myapp tried compiling both using the jar file and by adding the java directory and I still get the same error
image

@VirajCEO
Copy link

VirajCEO commented Jun 27, 2024

Do one thing try making a basic java class that would return hello world and then call it with pyjnius in python script and try changing the path again and again by doing hit and trial

Java code:

package com.github.hbldh.bleak

public class HelloWorld {
    public String sayHello() {
        return "Hello, World!";
    }

    public static void main(String[] args) {
        HelloWorld hw = new HelloWorld();
        System.out.println(hw.sayHello());
    }
}

now compile it whit this command

@VirajCEO
Copy link

VirajCEO commented Jun 27, 2024

javac HelloWorld.java

then lastly try to call it with pyjnius

import os
from jnius import autoclass
# Import the HelloWorld Java class
HelloWorld = autoclass('com.source.bleak.HelloWorld')

# Create an instance of the HelloWorld class
hw_instance = HelloWorld()

# Call the sayHello method
print(hw_instance.sayHello())

if you are able to call it then it means at least your directory placement is good then we will try fixing it with some other method

@VirajCEO
Copy link

VirajCEO commented Jun 27, 2024

For your convenience here is the java code

package com.github.hbldh.bleak;
public class HelloWorld {
    public String sayHello() {
        return "Hello, World!";
    }

    public static void main(String[] args) {
        HelloWorld hw = new HelloWorld();
        System.out.println(hw.sayHello());
    }
}

and here is the python code

import os
from jnius import autoclass

HelloWorld = autoclass('com.github.hbldh.bleak.HelloWorld')

hw_instance = HelloWorld()

print(hw_instance.sayHello())`

Sorry i didn't do it in one go just new in all this github issues thing

@ghost
Copy link

ghost commented Jun 27, 2024

which method should I use , android.add_jars or android.add_src ?
and thank you for providing the code ^^

@ghost
Copy link

ghost commented Jun 27, 2024

yup I got the same error :

image
here is my env :

image

and I have this in my buldozer.spec file :

android.add_src = java

@VirajCEO
Copy link

no no you don't need to compile the app with buildozer just run it on your pc to test weather the locaation of class file we are using is valid or not

remember to install pyjnius
with pip install pyjnius

just make test.py script in the project directory with the code i have provided to you earlier and then run it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants