turtleboy
turtleboy

Reputation: 7574

prebuilt .so library not recognized in Activity

I have been given a .so library called libremote_client.so

The library has a function called getInstance which returns an Object type IRemote. I have copied the .so file into my AndroidStudio project in the

app/src/main/jniLibs/armeabi/libremote_client.so

In my Activity I declare the following at class level

public native IRemote getInstance();

Unfortunately AndroidStudio cannot resolve the reference type IRemote. I obviously have not included the prebuilt .so file correctly in my project.

I think i may need to add some dependencies in my Gradle but i'm not sure where to start.

Below is my gradle file, can anyone show me how to add the .so file to my project correctly so my Activity can resolve the IRemote reference type?

Thanks in advance

Matt

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"



    defaultConfig {
        applicationId "devreach.co.uk.devreach"
        minSdkVersion 19
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            debuggable true
        }
    }
}

dependencies {
    compile fileTree(dir: 'jniLibs', include: ['*.jar'])

    compile 'com.android.support:appcompat-v7:22.2.0'
    compile files('libs/sqlcipher.jar')
    compile project(':ScreenSharingSDK')
    compile files('libs/joda-time-2.4.jar')
    compile files('libs/gcm.jar')
    compile project(':edm')
    compile project(':kcm')
    compile project(':rc')

}

Upvotes: 0

Views: 506

Answers (2)

mdtuyen
mdtuyen

Reputation: 4548

Add this line to gradle:

sourceSets {
    main {
        jni.srcDirs = [] 
        jniLibs.srcDir 'src/main/jniLibs'
    }
}

Upvotes: 1

Kai
Kai

Reputation: 15476

Whoever gave you the .so file forgot to give you the associated Java files, including IRemote and possibly more. Without IRemote.java interface class, how could you or the compiler know what methods can be called and what data are returned?

Also I've noticed that you have the line

compile fileTree(dir: 'jniLibs', include: ['*.jar'])

this is not needed and can be removed.

Upvotes: 0

Related Questions