I get a pyjnius error with a lot of class method accesses I expect to work:
Traceback (most recent call last):
File "jnius/jnius_export_class_pxi", line 752, in jnius.jnius.JavaMethod.__call__
File "jnius/jnius_export_class.pxi", line 699, in jnius.jnius.JavaMethod.ensure_method
jnius.jnius.JavaException: Unable to find a None method!
Steps to reproduce:
main.py
:from jnius import autoclass
python_activity = autoclass('org.kivy.android.PythonActivity')
window = python_activity.getWindow()
window.setSoftInputMode(16) # SOFT_INPUT_ADJUST_RESIZE
Package as .apk
:
p4a apk --arch=armeabi-v7a --name test --package com.example.test --version 1 --requirements=kivy,python2 --private .
(or python 3, you may need to add api and/or ndk api arguments if these aren't set in your path)
Run and wait until it instant-terminates, and then check logcat. You'll see this:
Traceback (most recent call last):
File "jnius/jnius_export_class_pxi", line 752, in jnius.jnius.JavaMethod.__call__
File "jnius/jnius_export_class.pxi", line 699, in jnius.jnius.JavaMethod.ensure_method
jnius.jnius.JavaException: Unable to find a None method!
Ok, I did some good old print debugging and the exact crashing line is window = python_activity.getWindow()
, or in bigger context:
However, I can't think of a case where the Activity
(which PythonActivity
/SDLActivity
derive from) wouldn't have getWindow()
as documented here: https://developer.android.com/reference/android/app/Activity#getWindow()
Is this a bug then?
FWIW, ran into the same error with https://github.com/kivy/python-for-android/pull/1772 . Anyone having a clue whether this is a pyjnius bug or a user error on my side?
The error here is calling the method on the Activity class, not instance, the instance is accessible through the mActivity
attribute.
here is a working code example https://gist.github.com/47b7b18855b38de3730e081682c558ce
hopefully it achieve what you are trying to do :).
closing as not a bug in pyjnius, please comment or reopen if you think this is wrong.
@tshirtman :balloon: :tada: thanks :heart:
Most helpful comment
closing as not a bug in pyjnius, please comment or reopen if you think this is wrong.