我在为这个问题苦思冥想了几天,现在正在不停地用头撞桌子。
我的原生Android应用程序在运行时加载一个类,我已经按照这篇教程的指导从资源文件夹中获取了dexed jar文件,并成功地加载了该类并调用了它的静态方法。
然而,如果我运行一个...
env->FindClass("TheClass");
...它抛出了一个Java异常。
这里是代码中相关的部分
//this works find and gives me a usable class
jclass shim_class = helper.LoadClassFromAssetsJar("test.jar","TheClass");
// this throws the exception
jclass refound_shim_class = jni->FindClass("TheClass");
任何帮助都将是不可思议的,朋友们加油!
JNI_OnLoad
中完成所有的FindClass
调用,或者在FindClass
调用中使用正确的类加载器。 - krsteeve