我有一个使用SDL(简单DirectMedia层)源的项目。当我运行此应用程序时,一切正常。但是我不重建共享库,这些库已经存在于jnilibs文件夹中。我的意思是,我尚未在ndkBuild { path 'src/main/jni/Android.mk' }
文件中添加任务build.gradle
。但是,现在我已将此应用程序更改为库,并添加到另一个应用程序。当我运行应用程序时,它给了我这些JNI错误。
A/zygote: java_vm_ext.cc:534] JNI DETECTED ERROR IN APPLICATION: GetStaticMethodID received NULL jclass
A/zygote: java_vm_ext.cc:534] in call to GetStaticMethodID
A/zygote: java_vm_ext.cc:534] from void org.libsdl.app.SDLActivity.nativeInit()
A/zygote: java_vm_ext.cc:534] "SDLThread" prio=5 tid=18 Runnable
A/zygote: java_vm_ext.cc:534] | group="main" sCount=0 dsCount=0 flags=0 obj=0x12d680b0 self=0xcf627c00
A/zygote: java_vm_ext.cc:534] | sysTid=15000 nice=0 cgrp=default sched=0/0 handle=0xcb1c2970
A/zygote: java_vm_ext.cc:534] | state=R schedstat=( 109480 0 1 ) utm=0 stm=0 core=5 HZ=100
A/zygote: java_vm_ext.cc:534] | stack=0xcb0c0000-0xcb0c2000 stackSize=1038KB
A/zygote: java_vm_ext.cc:534] | held mutexes= "mutator lock"(shared held)
A/zygote: java_vm_ext.cc:534] native: #00 pc 002e8367 /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, int, BacktraceMap*, char const*, art::ArtMethod*, void*)+130)
A/zygote: java_vm_ext.cc:534] native: #01 pc 00379111 /system/lib/libart.so (art::Thread::DumpStack(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, bool, BacktraceMap*, bool) const+204)
A/zygote: java_vm_ext.cc:534] native: #02 pc 00375847 /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, bool, BacktraceMap*, bool) const+34)
A/zygote: java_vm_ext.cc:534] native: #03 pc 0024d7dd /system/lib/libart.so (art::JavaVMExt::JniAbort(char const*, char const*)+720)
A/zygote: java_vm_ext.cc:534] native: #04 pc 0024db4b /system/lib/libart.so (art::JavaVMExt::JniAbortV(char const*, char const*, std::__va_list)+58)
A/zygote: java_vm_ext.cc:534] native: #05 pc 000d5fd3 /system/lib/libart.so (art::ScopedCheck::AbortF(char const*, ...)+42)
A/zygote: java_vm_ext.cc:534] native: #06 pc 000d5673 /system/lib/libart.so (art::ScopedCheck::CheckInstance(art::ScopedObjectAccess&, art::ScopedCheck::InstanceKind, _jobject*, bool)+390)
A/zygote: java_vm_ext.cc:534] native: #07 pc 000d4c6d /system/lib/libart.so (art::ScopedCheck::CheckPossibleHeapValue(art::ScopedObjectAccess&, char, art::JniValueType)+220)
A/zygote: java_vm_ext.cc:534] native: #08 pc 000d44fd /system/lib/libart.so (art::ScopedCheck::Check(art::ScopedObjectAccess&, bool, char const*, art::JniValueType*)+596)
A/zygote: java_vm_ext.cc:534] native: #09 pc 000d75b9 /system/lib/libart.so (art::CheckJNI::GetMethodIDInternal(char const*, _JNIEnv*, _jclass*, char const*, char const*, bool)+464)
A/zygote: java_vm_ext.cc:534] native: #10 pc 000cad5d /system/lib/libart.so (art::CheckJNI::GetStaticMethodID(_JNIEnv*, _jclass*, char const*, char const*)+20)
A/zygote: java_vm_ext.cc:534] native: #11 pc 000e517d /data/app/com.javadbadirkhanly.jbaemulator-Am-L9E1dng8yHEzBLULuXw==/lib/arm/libmain.so (SDL_Android_Init+552)
A/zygote: java_vm_ext.cc:534] native: #12 pc 000a358d /data/app/com.javadbadirkhanly.jbaemulator-Am-L9E1dng8yHEzBLULuXw==/lib/arm/libmain.so (Java_org_libsdl_app_SDLActivity_nativeInit+4)
A/zygote: java_vm_ext.cc:534] native: #13 pc 00405c79 /system/lib/libart.so (art_quick_generic_jni_trampoline+40)
A/zygote: java_vm_ext.cc:534] native: #14 pc 00401775 /system/lib/libart.so (art_quick_invoke_stub_internal+68)
A/zygote: java_vm_ext.cc:534] native: #15 pc 004069eb /system/lib/libart.so (art_quick_invoke_static_stub+226)
A/zygote: java_vm_ext.cc:534] native: #16 pc 000afedf /system/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+174)
A/zygote: java_vm_ext.cc:534] native: #17 pc 00200de7 /system/lib/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+226)
A/zygote: java_vm_ext.cc:534] native: #18 pc 001fc369 /system/lib/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+592)
答案 0 :(得分:0)
通过检查您的日志
A/zygote: java_vm_ext.cc:534] native: #11 pc 000e517d /data/app/com.javadbadirkhanly.jbaemulator-Am-L9E1dng8yHEzBLULuXw==/lib/arm/libmain.so (SDL_Android_Init+552)
A/zygote: java_vm_ext.cc:534] native: #12 pc 000a358d /data/app/com.javadbadirkhanly.jbaemulator-Am-L9E1dng8yHEzBLULuXw==/lib/arm/libmain.so (Java_org_libsdl_app_SDLActivity_nativeInit+4)
A/zygote: java_vm_ext.cc:534] native: #13 pc 00405c79 /system/lib/libart.so (art_quick_generic_jni_trampoline+40)
得知.so
路径为/lib/arm/libmain.so
/data/app/com.javadbadirkhanly.jbaemulator-Am-L9E1dng8yHEzBLULuXw == / lib / arm / libmain.so
对于最新的NDK,不再支持此ABI,对于相应的设备或仿真器体系结构,即.so
,armeabi-v7a
,{{1 }},arm64-v8a
。而且,您的.so路径应类似于
x86