我编写了一个代码,完全适用于我的手机(带有API 19的三星Galaxy S5)。但是当我尝试使用Android 4.2.2将项目上传到平板电脑时,它会引发错误。
我使用Eclipse。我清理了所有的项目。我在armeabi和armeabi-v7a中拥有相同的库。
以下是日志:
01-29 11:35:30.955: E/AndroidRuntime(16214): FATAL EXCEPTION: main
01-29 11:35:30.955: E/AndroidRuntime(16214): java.lang.ExceptionInInitializerError
01-29 11:35:30.955: E/AndroidRuntime(16214): at edu.cmu.pocketsphinx.demo.PersonRecognizer.<init>(PersonRecognizer.java:42)
01-29 11:35:30.955: E/AndroidRuntime(16214): at edu.cmu.pocketsphinx.demo.PocketSphinxActivity$1.onManagerConnected(PocketSphinxActivity.java:249)
01-29 11:35:30.955: E/AndroidRuntime(16214): at org.opencv.android.AsyncServiceHelper$1.onServiceConnected(AsyncServiceHelper.java:318)
01-29 11:35:30.955: E/AndroidRuntime(16214): at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1106)
01-29 11:35:30.955: E/AndroidRuntime(16214): at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1123)
01-29 11:35:30.955: E/AndroidRuntime(16214): at android.os.Handler.handleCallback(Handler.java:725)
01-29 11:35:30.955: E/AndroidRuntime(16214): at android.os.Handler.dispatchMessage(Handler.java:92)
01-29 11:35:30.955: E/AndroidRuntime(16214): at android.os.Looper.loop(Looper.java:176)
01-29 11:35:30.955: E/AndroidRuntime(16214): at android.app.ActivityThread.main(ActivityThread.java:5279)
01-29 11:35:30.955: E/AndroidRuntime(16214): at java.lang.reflect.Method.invokeNative(Native Method)
01-29 11:35:30.955: E/AndroidRuntime(16214): at java.lang.reflect.Method.invoke(Method.java:511)
01-29 11:35:30.955: E/AndroidRuntime(16214): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
01-29 11:35:30.955: E/AndroidRuntime(16214): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
01-29 11:35:30.955: E/AndroidRuntime(16214): at dalvik.system.NativeStart.main(Native Method)
01-29 11:35:30.955: E/AndroidRuntime(16214): Caused by: java.lang.ExceptionInInitializerError
01-29 11:35:30.955: E/AndroidRuntime(16214): at java.lang.Class.classForName(Native Method)
01-29 11:35:30.955: E/AndroidRuntime(16214): at java.lang.Class.forName(Class.java:217)
01-29 11:35:30.955: E/AndroidRuntime(16214): at com.googlecode.javacpp.Loader.load(Loader.java:453)
01-29 11:35:30.955: E/AndroidRuntime(16214): at com.googlecode.javacv.cpp.opencv_contrib.<clinit>(opencv_contrib.java:104)
01-29 11:35:30.955: E/AndroidRuntime(16214): ... 14 more
01-29 11:35:30.955: E/AndroidRuntime(16214): Caused by: java.lang.ExceptionInInitializerError
01-29 11:35:30.955: E/AndroidRuntime(16214): at java.lang.Class.classForName(Native Method)
01-29 11:35:30.955: E/AndroidRuntime(16214): at java.lang.Class.forName(Class.java:217)
01-29 11:35:30.955: E/AndroidRuntime(16214): at com.googlecode.javacpp.Loader.load(Loader.java:453)
01-29 11:35:30.955: E/AndroidRuntime(16214): at com.googlecode.javacv.cpp.opencv_calib3d.<clinit>(opencv_calib3d.java:94)
01-29 11:35:30.955: E/AndroidRuntime(16214): ... 18 more
01-29 11:35:30.955: E/AndroidRuntime(16214): Caused by: java.lang.ExceptionInInitializerError
01-29 11:35:30.955: E/AndroidRuntime(16214): at java.lang.Class.classForName(Native Method)
01-29 11:35:30.955: E/AndroidRuntime(16214): at java.lang.Class.forName(Class.java:217)
01-29 11:35:30.955: E/AndroidRuntime(16214): at com.googlecode.javacpp.Loader.load(Loader.java:453)
01-29 11:35:30.955: E/AndroidRuntime(16214): at com.googlecode.javacv.cpp.opencv_highgui.<clinit>(opencv_highgui.java:85)
01-29 11:35:30.955: E/AndroidRuntime(16214): ... 22 more
01-29 11:35:30.955: E/AndroidRuntime(16214): Caused by: java.lang.ExceptionInInitializerError
01-29 11:35:30.955: E/AndroidRuntime(16214): at java.lang.Class.classForName(Native Method)
01-29 11:35:30.955: E/AndroidRuntime(16214): at java.lang.Class.forName(Class.java:217)
01-29 11:35:30.955: E/AndroidRuntime(16214): at com.googlecode.javacpp.Loader.load(Loader.java:453)
01-29 11:35:30.955: E/AndroidRuntime(16214): at com.googlecode.javacv.cpp.opencv_imgproc.<clinit>(opencv_imgproc.java:97)
01-29 11:35:30.955: E/AndroidRuntime(16214): ... 26 more
01-29 11:35:30.955: E/AndroidRuntime(16214): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load jniopencv_core from loader dalvik.system.PathClassLoader[dexPath=/data/app/edu.cmu.pocketsphinx.demo-1.apk,libraryPath=/data/app-lib/edu.cmu.pocketsphinx.demo-1]: findLibrary returned null
01-29 11:35:30.955: E/AndroidRuntime(16214): at java.lang.Runtime.loadLibrary(Runtime.java:365)
01-29 11:35:30.955: E/AndroidRuntime(16214): at java.lang.System.loadLibrary(System.java:535)
01-29 11:35:30.955: E/AndroidRuntime(16214): at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:593)
01-29 11:35:30.955: E/AndroidRuntime(16214): at com.googlecode.javacpp.Loader.load(Loader.java:489)
01-29 11:35:30.955: E/AndroidRuntime(16214): at com.googlecode.javacpp.Loader.load(Loader.java:431)
01-29 11:35:30.955: E/AndroidRuntime(16214): at com.googlecode.javacv.cpp.opencv_core.<clinit>(opencv_core.java:136)
01-29 11:35:30.955: E/AndroidRuntime(16214): ... 30 more
01-29 11:35:30.955: E/AndroidRuntime(16214): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load opencv_core from loader dalvik.system.PathClassLoader[dexPath=/data/app/edu.cmu.pocketsphinx.demo-1.apk,libraryPath=/data/app-lib/edu.cmu.pocketsphinx.demo-1]: findLibrary returned null
01-29 11:35:30.955: E/AndroidRuntime(16214): at java.lang.Runtime.loadLibrary(Runtime.java:365)
01-29 11:35:30.955: E/AndroidRuntime(16214): at java.lang.System.loadLibrary(System.java:535)
01-29 11:35:30.955: E/AndroidRuntime(16214): at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:593)
01-29 11:35:30.955: E/AndroidRuntime(16214): at com.googlecode.javacpp.Loader.load(Loader.java:481)
01-29 11:35:30.955: E/AndroidRuntime(16214): ... 32 more
01-29 11:35:30.985: D/dalvikvm(16214): Rejecting registerization due to ushr-int/lit8 v4, v7, (#19)
01-29 11:35:30.995: D/dalvikvm(16214): Rejecting registerization due to ushr-int/lit8 v4, v7, (#19)
01-29 11:35:31.105: I/Process(16214): Sending signal. PID: 16214 SIG: 9
代码的一部分是
PersonRecognizer(String path)
{
faceRecognizer = com.googlecode.javacv.cpp.opencv_contrib.createLBPHFaceRecognizer(2,8,8,8,200);
// path=Environment.getExternalStorageDirectory()+"/facerecog/faces/";
mPath=path;
labelsFile= new labels(mPath);
}
答案 0 :(得分:2)
我认为this可能有所帮助。你必须自己编译库,不要直接导入二进制文件。
修改强>
从评论中我猜你正在使用三星galaxy tab 10.1,它使用Intel Atom我再次猜测是x86架构而不是{3}},就像你的三星Galaxy S5中使用的那样。所以你必须编译x86的源代码或将库的X86(二进制文件)文件夹导入到项目的libs文件夹中。
PS:从所有平台ARM
的源代码编译NDK的教程修改强> 平板电脑上的更多信息here