0

下载了 Affdex sdk,并试图让CameraDetectorDemo在我的 nexus 5 上运行。

我在尝试运行应用程序时遇到了以下异常。

07-23 11:16:19.020: D/dalvikvm(830): Not late-enabling CheckJNI (already on)
07-23 11:16:23.280: D/AndroidRuntime(830): Shutting down VM
07-23 11:16:23.280: W/dalvikvm(830): threadid=1: thread exiting with uncaught exception (group=0xada4aba8)
07-23 11:16:23.390: E/AndroidRuntime(830): FATAL EXCEPTION: main
07-23 11:16:23.390: E/AndroidRuntime(830): Process: com.affectiva.android.affdex.measureup, PID: 830
07-23 11:16:23.390: E/AndroidRuntime(830): java.lang.UnsatisfiedLinkError: Couldn't load affdexface_jni from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.affectiva.android.affdex.measureup-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.affectiva.android.affdex.measureup-1, /system/lib]]]: findLibrary returned null
07-23 11:16:23.390: E/AndroidRuntime(830):  at java.lang.Runtime.loadLibrary(Runtime.java:358)
07-23 11:16:23.390: E/AndroidRuntime(830):  at java.lang.System.loadLibrary(System.java:526)
07-23 11:16:23.390: E/AndroidRuntime(830):  at com.affectiva.android.affdex.sdk.detector.AffdexFaceJNI.<clinit>(AffdexFaceJNI.java:21)
07-23 11:16:23.390: E/AndroidRuntime(830):  at com.affectiva.android.affdex.sdk.detector.AffdexFaceJNI$$InjectAdapter.get(AffdexFaceJNI$$InjectAdapter.java:27)
07-23 11:16:23.390: E/AndroidRuntime(830):  at com.affectiva.android.affdex.sdk.detector.AffdexFaceJNI$$InjectAdapter.get(AffdexFaceJNI$$InjectAdapter.java:14)
4

1 回答 1

0

这很可能是由项目配置和导入库文件的方式错误引起的。

如果您在 Gradle 中构建项目,则需要遵循类似的结构,如下所示:

AffdexGradleProject
`-- app
|-- jniLibs
|   `-- armeabi-v7a
|       `-- libaffdexface_jni.so
|-- libs
|   |-- Affdex-sdk.jar
|   `-- Affdex-sdk-javadoc.jar
`-- src
|-- main
|   |-- assets
|   |   `-- Affdex
|   |       |-- Classifiers.v_9
|   |       |   `-- ...
|   |       `-- Affectiva.licence
|   |-- java
|   |   `-- ...
|   |-- res
|   |   `-- ...
|   `-- AndroidManifest.xml
|-- app.iml
`-- build.gradle

只要您的项目配置正确以引用它们,libs 和 jniLibs 文件夹的位置并不重要。

这是 build.gradle 的片段,它引用了上面的 libs 和 jniLibs 的位置以进行比较:

android {
    ...

    sourceSets {
        main {
            jniLibs.srcDirs = ['jniLibs']
            jni.srcDirs = [] //disable automatic ndk-build
        }
    }
    ndk {
        abiFilters “armeabi-v7a”, ... (what ever other architecture types additional libraries are using)
    }
}

dependencies {
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.squareup.dagger:dagger:1.2.2'
    compile 'javax.inject:javax.inject:1'
    compile files('libs/Affdex-sdk.jar')
    compile files('libs/Affdex-sdk-javadoc.jar')
}


于 2015-12-14T07:08:47.470 回答