Hi,
I am using the GameActivity and I need to instanciate a Java class that I wrote. This class is not referenced anywhere on the Java side but it is present in the APK. When I call env.find_class inside my android_main function, I get a ClassNotFoundException. I have read that this could happen inside a thread not spawned by the JVM that would use the default ClassLoader. I have also found this comment just before the call to android_main:
// XXX: If we were in control of the Java Activity subclass then
// we could potentially run the android_main function via a Java native method
// springboard (e.g. call an Activity subclass method that calls a jni native
// method that then just calls android_main()) that would make sure there was
// a Java frame at the base of our call stack which would then be recognised
// when calling FindClass to lookup a suitable classLoader, instead of
// defaulting to the system loader. Without this then it's difficult for native
// code to look up non-standard Java classes.
I think this explain my issue. Is there a typical way around this? I've heard about the JNI_OnLoad function, but I'm afraid it would interfear.
How difficult whould it be to lift this limitation, if it is something doable?
Thanks for this amazing crate!
Hi,
I am using the GameActivity and I need to instanciate a Java class that I wrote. This class is not referenced anywhere on the Java side but it is present in the APK. When I call
env.find_classinside myandroid_mainfunction, I get a ClassNotFoundException. I have read that this could happen inside a thread not spawned by the JVM that would use the default ClassLoader. I have also found this comment just before the call toandroid_main:I think this explain my issue. Is there a typical way around this? I've heard about the
JNI_OnLoadfunction, but I'm afraid it would interfear.How difficult whould it be to lift this limitation, if it is something doable?
Thanks for this amazing crate!