I'm also hitting this issue.
Here is the section of java that implements an interface override method, from the github project I am trying to use for reference on my Kivy project:
from kivy.app import App #for the main app from kivy.uix.floatlayout import FloatLayout #the UI layout
from kivy.uix.label import Label #a label to show information
from kivy.uix.button import Button
from plyer import accelerometer #object to read the accelerometer
from kivy.clock import Clock #clock to schedule a method
from kivy.uix.boxlayout import BoxLayout
#########
# 'autoclass' takes a java class and gives it a Python wrapper
from jnius import autoclass
# Constants = autoclass('com.htc.lib1.duallens.Constants')
from jnius import PythonJavaClass
from jnius import java_method
# OnCompletionListener = autoclass('com.htc.lib1.duallens.DualLens$OnCompletionListener')
DualLens = autoclass('com.htc.lib1.duallens.DualLens')
_File = autoclass('java.io.File')
Environment = autoclass('android.os.Environment')
# PythonActivity is provided by the Kivy bootstrap app in python-for-android
PythonActivity = autoclass('org.renpy.android.PythonActivity')
activity = PythonActivity.mActivity
filename = "dualLensSample.jpg";
filepath = '{}{}{}'.format(Environment.getExternalStorageDirectory().getAbsolutePath(), _File.separator, filename)
self.d = DualLens(activity, filepath)
class ac(PythonJavaClass):
__javainterfaces__ = ['com/htc/lib1/duallens/DualLens$OnCompletionListener']
#class onCompletion(OnCompletionListener):
# onCompletion(DualLens dualLens, int what, int extra, java.lang.String filePath)
@java_method('(com/htc/lib1/duallens/DualLens;I;I;java/lang/String;)V;')
def onCompletion(arg0, event, extra, path):
print '{} $$$ {}'.format(arg0, event)
self.d.setOnCompletionListener(ac())
self.d.prepare()
The error is coming up for the second-to-last line "self.d.setOnCompletionListener(ac())" when I try to instantiate the object:
08-29 23:52:29.402 4904 4924 I python : Traceback (most recent call last):
08-29 23:52:29.403 4904 4924 I python : File "/home/nathan/Projects/kivy_test/.buildozer/android/app/main.py", line 107, in <module>
08-29 23:52:29.405 4904 4924 I python : File "/home/nathan/Projects/kivy_test/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/app.py", line 802, in run
08-29 23:52:29.407 4904 4924 I python : File "/home/nathan/Projects/kivy_test/.buildozer/android/app/main.py", line 103, in build
08-29 23:52:29.408 4904 4924 I python : File "/home/nathan/Projects/kivy_test/.buildozer/android/app/main.py", line 88, in __init__
08-29 23:52:29.410 4904 4924 I python : File "jnius_proxy.pxi", line 31, in jnius.jnius.PythonJavaClass.__init__ (jnius/jnius.c:25663)
08-29 23:52:29.411 4904 4924 I python : File "jnius_proxy.pxi", line 183, in jnius.jnius.create_proxy_instance (jnius/jnius.c:27889)
08-29 23:52:29.412 4904 4924 I python : File "jnius_export_class.pxi", line 637, in jnius.jnius.JavaMethod.__call__ (jnius/jnius.c:21397)
08-29 23:52:29.414 4904 4924 I python : File "jnius_export_class.pxi", line 803, in jnius.jnius.JavaMethod.call_staticmethod (jnius/jnius.c:23238)
08-29 23:52:29.415 4904 4924 I python : File "jnius_utils.pxi", line 93, in jnius.jnius.check_exception (jnius/jnius.c:3765)
08-29 23:52:29.416 4904 4924 I python : jnius.jnius.JavaException: JVM exception occurred: interface com.htc.lib1.duallens.DualLens$OnCompletionListener is not visible from class loader
Also, this project has both a .jar file and a .so file which seem to contain references to the same class namespace (I don't know if that is the right term for Java, me coming from a Python background):
one of these:
The best I can think is buildozer/kivy/python-for-android is getting confused about the two different sources of class-namespace... but I'd love to hear a solution nonetheless!
Please and thanks!