I was following an OpenCV Installation and SIFT Tutorial for Android Studio. I did everything exactly as the video tutorial said for me to do, and I've probably redone it 10 times now on 3 different computers, but I always get the same problem. The gradle will build without a problem, so there aren't any errors in the code, but when I run the app on an emulator, the app will crash immediately.
Here is my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.example.anita.opencvtestattempt3"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',
{
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile project(':libraries:opencv')
}
and here is the logcat when I run the app:
07-17 16:07:51.309 4369-4369/? I/art: Not late-enabling -Xcheck:jni (already
on)
07-17 16:07:51.309 4369-4369/? W/art: Unexpected CPU variant for X86 using
defaults: x86
07-17 16:07:51.404 4369-4369/com.example.anita.opencvtestattempt3
I/InstantRun: starting instant run server: is main process
07-17 16:07:51.422 4369-4369/com.example.anita.opencvtestattempt3
D/AndroidRuntime: Shutting down VM
07-17 16:07:51.423 4369-4369/com.example.anita.opencvtestattempt3
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.anita.opencvtestattempt3, PID: 4369
java.lang.UnsatisfiedLinkError: dlopen failed: file offset for the library
"/data/app/com.example.anita.opencvtestattempt3-2/lib/x86/libopencv_java.so"
>= file size: 0 >= 0
at java.lang.Runtime.loadLibrary0(Runtime.java:977)
at java.lang.System.loadLibrary(System.java:1530)
at com.example.anita.opencvtestattempt3.MainActivity.<clinit>
(MainActivity.java:18)
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newActivity(Instrumentation.java:1078)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2538)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at
com.android.internal.os.ZygoteInit$MethodAndArgsC
aller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)