I have an android app with native code where I use openCV library. When running the app in phone everything is working well but when I try to run it on tablet(Lenovo yoga 2 pro) I am encountering this error:
01-03 11:53:13.007: E/AndroidRuntime(25632): FATAL EXCEPTION: main
01-03 11:53:13.007: E/AndroidRuntime(25632): Process: <appname>, PID: 25632
01-03 11:53:13.007: E/AndroidRuntime(25632): java.lang.UnsatisfiedLinkError: dlopen failed: "/data/app-lib/<appname>/libnative_module.so" has unexpected e_machine: 40
01-03 11:53:13.007: E/AndroidRuntime(25632): at java.lang.Runtime.loadLibrary(Runtime.java:364)
01-03 11:53:13.007: E/AndroidRuntime(25632): at java.lang.System.loadLibrary(System.java:526)
01-03 11:53:13.007: E/AndroidRuntime(25632): at <appname>.SplashActivity$1.onManagerConnected(SplashActivity.java:35)
01-03 11:53:13.007: E/AndroidRuntime(25632): at org.opencv.android.AsyncServiceHelper$1.onServiceConnected(AsyncServiceHelper.java:318)
01-03 11:53:13.007: E/AndroidRuntime(25632): at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1127)
01-03 11:53:13.007: E/AndroidRuntime(25632): at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1144)
01-03 11:53:13.007: E/AndroidRuntime(25632): at android.os.Handler.handleCallback(Handler.java:733)
01-03 11:53:13.007: E/AndroidRuntime(25632): at android.os.Handler.dispatchMessage(Handler.java:95)
01-03 11:53:13.007: E/AndroidRuntime(25632): at android.os.Looper.loop(Looper.java:149)
01-03 11:53:13.007: E/AndroidRuntime(25632): at android.app.ActivityThread.main(ActivityThread.java:5283)
01-03 11:53:13.007: E/AndroidRuntime(25632): at java.lang.reflect.Method.invokeNative(Native Method)
01-03 11:53:13.007: E/AndroidRuntime(25632): at java.lang.reflect.Method.invoke(Method.java:515)
01-03 11:53:13.007: E/AndroidRuntime(25632): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:825)
01-03 11:53:13.007: E/AndroidRuntime(25632): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641)
01-03 11:53:13.007: E/AndroidRuntime(25632): at dalvik.system.NativeStart.main(Native Method)
this is on the line 45 in SplashActivity:
System.loadLibrary("native_module");
Can someone help me to solve this error? or What am I doing wrong?
Your tablet is based on Intel Atom CPU. You must build your native_module for APP_ABI=x86
. Note that you also need the compatible version of OpenCV.
Update: in this particular case, the app was built for both x86 and ARM. But the app installer chose the wrong subfolder, maybe because the filenames listed in libs/x86
and libs/armeabi
did not exactly match. The reliable and efficient approach for apps that have non-trivial native component is to upload separate APKs to PlayStore.