我正在使用JavaCV开发一个人脸识别系统。我同时使用OpenCV和JavaCV。我还使用AndroidStudio。然而,它显示了这个错误。
12-20 00:22:25.315 6018-6018/com.example.nasif.xiomi_face E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.nasif.xiomi_face, PID: 6018
java.lang.NoClassDefFoundError: java.lang.ClassNotFoundException: org.bytedeco.javacpp.opencv_core
at org.bytedeco.javacpp.Loader.load(Loader.java:590)
at org.bytedeco.javacpp.Loader.load(Loader.java:530)
at org.bytedeco.javacpp.opencv_core$MatVector.<clinit>(opencv_core.java:475)
at com.example.nasif.xiomi_face.Myjavacvface.training_facerecognition(Myjavacvface.java:58)
at com.example.nasif.xiomi_face.MainActivity.onOptionsItemSelected(MainActivity.java:148)
at android.app.Activity.onMenuItemSelected(Activity.java:2644)
at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:368)
at android.support.v7.app.AppCompatActivity.onMenuItemSelected(AppCompatActivity.java:195)
构建分级机
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.nasif.xiomi_face"
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 {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
// add
compile 'com.google.android.gms:play-services-vision:11.6.2'
compile 'org.bytedeco:javacv:1.1'
compile 'org.bytedeco.javacpp-presets:opencv:3.0.0-1.1'
implementation files('libs/jxl-2.6.12.jar')
implementation project(':openCVLibrary24134')
}
你能帮我解决这个问题吗?谢谢。
1条答案
按热度按时间mkshixfv1#
如果有人有类似的问题,那么解决方案是:在gradle中添加这3行,然后构建它。
备选方案: