-
Notifications
You must be signed in to change notification settings - Fork 295
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
Comments
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. |
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. |
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. |
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. |
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. |
Hello ! same problem. |
Hi ! I think just the package i have tell in previous post. |
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... |
Thanks. it didn't work for me. The advice above helped me...
|
Yes curious thing...perhaps clean all buildozer and reinstall clean ..How do you install buildozer ? Pip or package distrib ? |
pip3 install buildozer |
So, it's August 2023 and pylogger-html's solution is still the workaround for this issue. Thank you, pylogger-html. |
@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 |
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
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 run this command now finally in your buildozer.spec file and you will be good to go ;) |
Copy and paste the above links for some reason they are not working when you click them |
fixed |
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): |
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 |
|
where is your main.py file? here in the screenshot of the directory you shared? is this your source directory? |
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 = . |
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 |
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 |
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 |
which method should I use , android.add_jars or android.add_src ? |
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 just make test.py script in the project directory with the code i have provided to you earlier and then run it |
bluetoothctl -v
) in case of Linux: 5.53Description
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:
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.
The text was updated successfully, but these errors were encountered: