pyjnius | Access Java classes from Python | Wrapper library
kandi X-RAY | pyjnius Summary
kandi X-RAY | pyjnius Summary
A Python module to access Java classes as Python classes using the Java Native Interface (JNI). Warning: the pypi name is now pyjnius instead of jnius.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Returns a Java class for the given class name .
- Try to load the libjjb .
- Get java .
- This method is used to log a method .
- Gets the JDK home .
- Get the JRE home directory .
- Get classloader .
- Compile native invocation handler .
- Get item at index .
- Identify a class with a concrete level .
pyjnius Key Features
pyjnius Examples and Code Snippets
#sudo pip install Cython
#sudo pip install pyjnius
from plyer.vibrator import vibrate
vibrate(10) # in Plyer, the argument is in seconds
from jnius import autoclass
# We need a reference to the Java activity running the current
# application, this reference is stored automatically by
# Kivy's PythonActivity bootstrap
# This one works with SDL2
PythonActivity = autoclass('org.kivy.andr
requirements = hostpython3==3.7.8,python3==3.7.8,kivy==1.11.1, certifi,chardet, lxml, docutils, future, idna, Kivy-Garden, Pygments, requests, six, soupsieve, urllib3, deep-translator, arabic-reshaper, python-bidi, openssl, pyopenssl, nump
from android.permissions import Permission, request_permissions
def callback_func(permission, results):
if all([res for res in results):
print("All permissions granted")
else:
print("Did not get all permissions")
request_permi
# comma separated e.g. requirements = sqlite3,kivy
requirements = python3,kivy==2.0.0,kivymd==0.104.1,pluginname==version
requirements = kivy==2.0.0,kivymd==0.104.1,python3,pyjnius,plyer,requests,urllib3,chardet,idna,pip,Image,PIL,watchdog
Community Discussions
Trending Discussions on pyjnius
QUESTION
I created an APK from Python Kivy & KivyMD, using Google colab.
after installing it in my phone (android) , it crashed.
there two file in my project main.py, main.json, I have correctly listed Kivy & KivyMD in the requirements in the Buildozer.spec file. (kivy==2.0.0,kivymd==0.104.2) and I add json to included source like this:
source.include_exts = py,png,jpg,kv,atlas,json
This is my code..
main.py: it is a simple Notes app I think that there is no error
...ANSWER
Answered 2022-Jan-31 at 09:12I have also solved this problem and this helped me. Buildozer requirements is: python3,kivy==2.0.0,kivymd==0.104.2,pillow==8.0.1
QUESTION
I'm making a kivy app for samsung and compiling it using buildozer, ubuntu on windows.
This is .spec file:
...ANSWER
Answered 2022-Jan-25 at 15:35I had same issue in past and I solve by adding every requirements in .spec
This requirements work for me:
QUESTION
I'm somewhat new to Ubuntu (16.04, armhf) and am trying to use pytimeextractor which requires both cython and pyjnius to enable the Java/Python interaction, but am running into the following error with pyjnius:
SystemError: Error calling dlopen(b'/usr/lib/jvm/jdk1.8.0-openjdk-armhf/jre/lib/arm/server/libjvm.so': b'/usr/lib/jvm/jdk1.8.0-openjdk-armhf/jre/lib/arm/server/libjvm.so: cannot open shared object file: No such file or directory'
I was initially having issues with setting JAVA_HOME (getting a KeyError), which lead me to purge existing Java installations such as the folder referenced in the SystemError above: "*/jdk1.8.0-openjdk-armhf/..."
After reinstalling Java and setting JAVA_HOME in etc/environment, then uninstalling and reinstalling pyjnius, it is still pointing to this old, now non-existent Java installation... rather than the JAVA_HOME now set (/usr/lib/jvm/java-1.8.0-openjdk-armhf) and I have not the slightest idea why.
Could someone please help point me in the right direction of resolving this issue? I feel out of my depth with the extent of Ubuntu knowledge required to accurately diagnose the errors in front of me and swiftly resolve them. Thank you.
...ANSWER
Answered 2022-Jan-10 at 03:05I have managed to resolve this issue. As far as I can tell, I had set the JAVA_HOME to point at the correct installation of Java but needed to log out and back in for the changes to take effect.
QUESTION
I am trying to create a kivy app for android device. And my code is working great on the PC. But the apk file created using buildozer is not really working on the android. It crashes before opening. But a simple Hello World Example works perfect With the same spec file.. I am not at all using any external modules in the app. Only socket module (which is a python core module.)
I don't know, what is happening. So I used socket to create a functionality to try the code and in exception I have given the code to send the Exception to my IP. Also I am having a program ready to receive and print the signal. Both these things worked great on the PC. But apk still crashes. Without sending any logs to my PC.
Here is the spec file:
...ANSWER
Answered 2021-Oct-21 at 04:06Remove comment from android.permissions = INTERNET,
then it may work.
QUESTION
I have created an APK file from Python Kivy & KivyMD, using Buildozer. When I open the app after installing it, it shows the splash image and then closes. I have checked and found that their seems no issue in the main.py, as I have correctly listed Kivy & KivyMD in the requirements in the Buildozer.spec file. (kivy==2.0.0,kivymd==0.104.1)
This is my code..
main.py
...ANSWER
Answered 2021-Oct-16 at 08:18If you have some other plugins just add them like this:
QUESTION
from kivy.uix.screenmanager import Screen from plyer import call from plyer.platforms.android import activity from kivy.utils import platform import os
...ANSWER
Answered 2021-Aug-25 at 14:54plyer call method works only on android and iOS as descripted here here
QUESTION
I'm trying to make kivy app for android that has some simple network features. The app works fine on pc but when I try to import it to android it doesn't work anymore. At first my app crashed on startup which was apparently caused by having network stuff on my main thread so I moved all the network stuff to another thread so my app doesn't crash anymore but it doesn't work either. Here is where I make new thread for networking:
...ANSWER
Answered 2021-Aug-12 at 12:25You don't need android.permissions
in your requirements
, but you will need the line:
QUESTION
I'm a newbie at Python and Kivy as well, so please help me.
So I wanted to compile my app to .apk
and found a guide video on YouTube.(I'm using Windows btw)
Here it is - https://www.youtube.com/watch?v=D0reWInYl6k&ab_channel=SBDeveloper
So, when I was editing buildozer.spec
I noticed that author didn't set the latest KivyMD version, so I did.
And it compiled succesfully, but when I opened it on my phone, it showed the kivy loading screen and then just crashed.
I searched a lot what is the problem but didn't understand anything.
Here is buildozer.spec
file:
ANSWER
Answered 2021-Aug-13 at 09:58Short version: buildozer -v android debug deploy run logcat
to know what is the problem.
_
Long version:
After having done a lot of kivy app I can give the best advice you will ever have: do "Hello World" (which means do the tiniest possible working code). Actually, without error message and that much possibility of crashing without all the information your title is not Kivy/KivyMD application crashes on Android after compiling to .apk but HELP ME which is time consuming...
Problems:
- Trying to import that much stuff without having a working MVP app is madness.
- You are importing MD stuff which evolve quickly and can easely work on a version and crash on another.
- You are using storage without asking it on the buildozer.
- You don't show your python code even if you are actually crashing on the
build/on_kv_post
. - You need to use
buildozer -v android debug deploy run logcat
to get visual on your errors by connecting your phone to your PC.
If you had done step by step, you would have pass from Kivy/KivyMD application crashes on Android after compiling to .apk to something like: Why does the MDWidgetXXX is not working on Android or Kivy: How to register file on Android
QUESTION
ANSWER
Answered 2021-Jul-28 at 22:52In order for everything to work correctly and the example below to run, you need to perform the following steps:
On your PC:
QUESTION
I am new to kivy and it's my first build with the kivy, I used google collab for the compilation environment ,Error is very time open my app it loads and shows pre splash screen and then it crashes, I have also tried adb for getting logs but it doesn't give any info, here is the link to the apk
here is my app code
...ANSWER
Answered 2021-Jul-15 at 12:56I have a tip for using the log.txt , instead of this , you can use real-time logs and it filters only python log here is the command..
It can be hard to look for errors in log.txt , best method is to search for these keyword. No Module, No NameError , Traceback , indentation error
Command to filter python logs while deployin on device
buildozer android deploy run logcat | grep python
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install pyjnius
You can use pyjnius like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page