2016-07-09 3 views
0

Android Studio에서 JavaCV를 사용하려고합니다. FaceRecognizer 클래스의 래퍼를 사용하려고합니다. 나는 몇 시간 동안이 코드를 실행하려고 시도했지만 지금까지는 운이 없다. 나는 빌드 오류가 계속 : JavaCV Android Studio 사용 문제

 Error:A problem occurred configuring project ':app'. 
    > Could not find javacpp-presets-Mac OS X-x86_64.jar 
     (org.bytedeco:javacpp-presets:1.2). 
     Searched in the following locations: 
     https://jcenter.bintray.com/org/bytedeco/javacpppresets/1.2/javacpp-presets-1.2-Mac OS X-x86_64.jar' 

나는 두 개의 파일로 OpenCV의 분할에 대한 .so는 파일의 압축을 푼 : armeabi 및 x86, 그래서 잘 이잖아.

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.3" 
    sourceSets.main.jni.srcDirs = [] 

    //task ndkBuild(type: Exec, description: 'Compile JNI source via NDK') { 
    // ndkDir = project.plugins.findPlugin('com.android.application').sdkHandler.getNdkFolder() 
    // //on Windows, you need to add ".cmd" after "ndk-build" below 
    // commandLine "$ndkDir/ndk-build", 
    //   'NDK_PROJECT_PATH=build/intermediates/ndk', 
    //   'NDK_LIBS_OUT=src/main/jniLibs', 
    //   'APP_BUILD_SCRIPT=src/main/jniLibs/Android.mk', 
    //   'NDK_APPLICATION_MK=src/main/jniLibs/Application.mk' 
    //} 
    //task ndkLibsToJar(type: Zip, dependsOn: 'ndkBuild', description: 'Create a JAR of the native libs') { 
    // destinationDir new File(buildDir, 'libs') 
    // baseName 'ndk-libs' 
    // extension 'jar' 
    // from(new File(buildDir, 'libs')) { include '**/*.so' } 
    // into 'lib/' 
    //} 
    //tasks.withType(JavaCompile) { 
    // compileTask -> compileTask.dependsOn ndkBuild 
    //} 
    defaultConfig { 
     applicationId "com.example.manavdutta1.affdexdemo" 
     minSdkVersion 19 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 
    } 
    packagingOptions { 
     exclude 'META-INF/LICENSE.txt' 
     exclude 'META-INF/NOTICE.txt' 
     //exclude 'META-INF/maven/org.bytedeco.javacpp-presets/ffmpeg/pom.properties' 
     //exclude 'META-INF/maven/org.bytedeco.javacpp-presets/ffmpeg/pom.xml' 

     //might need these if you use openCV 
     exclude 'META-INF/maven/org.bytedeco.javacpp-presets/opencv/pom.properties' 
     exclude 'META-INF/maven/org.bytedeco.javacpp-presets/opencv/pom.xml' 
    } 
    buildTypes { 
     release { 
      minifyEnabled true 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 
    dependencies { 
     compile fileTree(include: ['*.jar'], dir: 'libs') 
     compile fileTree(dir: new File(buildDir, 'libs'), include: '*.jar') 
     testCompile 'junit:junit:4.12' 
     compile project(path: ':openCVLibrary2411') 
     compile files('src/main/libs/faceapi.jar') 
     compile files('src/main/libs/faceppsdk.jar') 
     //compile files('src/main/libs/artoolkitplus.jar') 
     //compile files('src/main/libs/ffmpeg.jar') 
     //compile files('src/main/libs/flandmark.jar') 
     //compile files('src/main/libs/flycapture.jar') 
     //compile files('src/main/libs/javacpp.jar') 
     //compile files('src/main/libs/javacv.jar') 
     //compile files('src/main/libs/arm/opencv-android-arm.jar') 
     //compile files('src/main/libs/x86/opencv-android-x86.jar') 
     //compile files('src/main/libs/libdc1394.jar') 
     //compile files('src/main/libs/libfreenect.jar') 
     //compile files('src/main/libs/opencv.jar') 
     //compile files('src/main/libs/videoinput.jar') 
     compile 'com.android.support:appcompat-v7:23.3.0' 
     compile 'com.affectiva.android:affdexsdk:3.0.1' 
     compile 'com.microsoft.projectoxford:face:1.0.0' 
     compile 'com.microsoft.projectoxford:emotion:1.0.0' 
     compile 'com.android.support:design:23.3.0' 
     compile 'org.bytedeco:javacv:1.2' 
     compile 'org.bytedeco.javacpp-presets:opencv:3.0.0-1.1:android-x86' 
     compile 'org.bytedeco.javacpp-presets:opencv:3.0.0-1.1:android-arm' 
     //compile group: 'org.bytedeco', name: 'javacv', version: '1.2' 

     //compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '2.4.10-0.10', classifier: 'android-arm' 
     //compile group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: '2.5.1-0.10', classifier: 'android-arm' 

    } 

임 확실하지 않은 방법 여기에서 진행 :

여기 내 build.gradle 파일입니다. 이 컴파일을 위해 build.gradle에 어떤 수정을해야합니까? javacv 1.1을 사용했지만 런타임에 오류가 발생했으며 .so 파일은 모두 javacv 1.2에서 가져 왔습니다.

답변

1

나는 비슷한 문제가있었습니다. Gradle의 의존성 해결에 버그가있는 것 같습니다. Javacpp의 저자는 이미 해결 방법을 제공하고, 여기 참조 : https://github.com/bytedeco/javacv/issues/432

시도가 build.gradle 스크립트에 다음 코드를 포함 :

configurations { 
    all*.exclude group: 'org.bytedeco', module: 'javacpp-presets' 
} 

그것은 나를 위해 작동과 희망이 당신을 위해 할 것입니다.

+0

감사합니다. 나는 또 다른 문제가있다. 안드로이드 세트에서 코드를 업로드하면 다음 오류가 표시됩니다. 09-18 12 : 49 : 23.161 15771-15771/com.example.nasif.myapplication E/AndroidRuntime : FATAL 예외 : mainProcess : com.example.nasif.myapplication, PID : 15771 java.lang.NoClassDefFoundError : java.lang.ClassNotFoundException : org.bytedeco.javacpp.opencv_core – user1850484