0

I downloaded the Affdex sdk, and I'm trying to get CameraDetectorDemo to run on my nexus 5.

I encountered an the following exception trying to run the application.

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)
emotionbot
  • 59
  • 3

1 Answers1

0

This is most likely caused by an error in the way the project is configured and is importing the library files.

If you are building your project in Gradle, you need to follow a similar structure as shown here:

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

The location of the libs and jniLibs folders do not really matter as long as your project is configured properly to reference them.

And here is the snippet of the build.gradle that references the locations of the libs and jniLibs above for comparison:

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')
}


ahamino
  • 554
  • 1
  • 3
  • 11