我正在关注Android Studio的OpenCV安装和SIFT教程。我完全按照视频教程的说法做了一切,我现在可能在3台不同的计算机上重做了10次,但我总是遇到同样的问题。 gradle将构建没有问题,因此代码中没有任何错误,但是当我在模拟器上运行应用程序时,应用程序将立即崩溃。
这是我的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')
}
这是我运行应用程序时的logcat:
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)