0

There's a problem whenever I build my project to my phone (Android 4.4.2).

I get the UnsatisfiedLinkError and it seems that the alljoyn library is not yet loaded. The only thing that I've added is static { System.loadLibrary("alljoyn_java"); } before the onCreate() method of the Main activity.

Here is the build.gradle file for reference:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.3"
    defaultConfig {
        applicationId "secret.secret.secret"
        minSdkVersion 19
        targetSdkVersion 24
        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')
    compile files('src/main/java/jniLibs/alljoyn.jar')
    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:24.2.1'
    testCompile 'junit:junit:4.12'
}

Project Directory Android Studio version

Maybe I'm using the wrong android sdk. What could be the problem? Thanks for the help!

2 Answers2

0

I followed the instructions here except that I placed the jar file inside the app/libs/ folder.

One good point that I see here is that the jar file can be anywhere but the .so file must be at the app/src/main/jniLibs/armeabi/. I don't know the reason behind this -- can someone explain why?

Community
  • 1
  • 1
0

The app/src/main/jniLibs/armeabi/ location is the default one. You can specify a custom location adding:

sourceSets.main {
        jniLibs.srcDir 'your/custom/location' 
}

to

android {
   ...
}
Lino
  • 5,084
  • 3
  • 21
  • 39