我有一个从Java源代码创建的RunTest.dex文件,我试图在我的Android设备(Galaxy S4)上使用" dalvikvm -cp RunTest.dex Runtest&#运行它34 ;.我的问题是我的程序对共享库进行了jni调用,但链接器找不到我的共享库,即使它与我的.dex文件位于同一目录中。我用ndk-build创建了共享库,所以我知道它已经正确构建。
来自控制台的错误消息:
shell@jfltevzw:/sdcard/Download $ dalvikvm -cp RunTest.dex RunTest
Unable to find static main(String[]) in 'RunTest'
java.lang.UnsatisfiedLinkError: Couldn't load eitTest from loader dalvik.system.PathClassLoader[dexPath=RunTest.dex,libraryPath=null]: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:358)
at java.lang.System.loadLibrary(System.java:526)
at RunTest.<clinit>(RunTest.java:5)
at dalvik.system.NativeStart.main(Native Method)
java.lang.UnsatisfiedLinkError: Couldn't load eitTest from loader dalvik.system.PathClassLoader[dexPath=RunTest.dex,libraryPath=null]: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:358)
at java.lang.System.loadLibrary(System.java:526)
at RunTest.<clinit>(RunTest.java:5)
at dalvik.system.NativeStart.main(Native Method)
Java源代码:
class RunTest{
native void eitTest();
static{
System.loadLibrary("eitTest");
}
public static void main(String[] args){
RunTest runTest = new RunTest();
runTest.eitTest();
}
}
原生代码:
#include <jni.h>
#include <stdio.h>
JNIEXPORT void JNICALL Java_RunTest_eitTest(JNIEnv *env, jobject jobj){
printf("Hello From C!!!\n");
}
我还设置了&#34; ANDROID_DATA = / sdcard / Download&#34;,其中我有一个dalvik-cache文件夹。