在處理此問題幾天之後,我目前正在將我的桌子撞上。對於在運行時從jar文件中加載的類的FindClass
我的原生android應用程序在運行時加載一個類,這個工程我遵循this tutorial從資產文件夾中獲取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
有關如何解決[FindClass問題](http://developer.android.com/)的示例,請參見http://stackoverflow.com/questions/13263340/findclass-from-any-thread-in-android-jni guide/practices/jni.html#faq_FindClass)。我會說:如果你已經從你的裝載機上得到了這個課程,那就留待將來使用! –