简体   繁体   English

在活动中无法识别的预建.so库

[英]prebuilt .so library not recognized in Activity

I have been given a .so library called libremote_client.so 我得到了一个名为libremote_client.so的.so库。

The library has a function called getInstance which returns an Object type IRemote. 该库具有一个名为getInstance的函数,该函数返回对象类型IRemote。 I have copied the .so file into my AndroidStudio project in the 我已将.so文件复制到我的AndroidStudio项目中,

app/src/main/jniLibs/armeabi/libremote_client.so 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. 不幸的是,AndroidStudio无法解析引用类型IRemote。 I obviously have not included the prebuilt .so file correctly in my project. 我显然没有在项目中正确包含预构建的.so文件。

I think i may need to add some dependencies in my Gradle but i'm not sure where to start. 我认为我可能需要在Gradle中添加一些依赖项,但是我不确定从哪里开始。

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? 以下是我的gradle文件,谁能告诉我如何将.so文件正确添加到我的项目中,以便我的Activity可以解决IRemote引用类型?

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

}

Add this line to gradle: 将此行添加到gradle中:

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

Whoever gave you the .so file forgot to give you the associated Java files, including IRemote and possibly more. 凡是给您.so文件的人都忘记了为您提供相关的Java文件,包括IRemote以及可能更多的文件。 Without IRemote.java interface class, how could you or the compiler know what methods can be called and what data are returned? 没有IRemote.java接口类,您或编译器如何知道可以调用哪些方法以及返回什么数据?

Also I've noticed that you have the line 我也注意到你有线

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

this is not needed and can be removed. 这是不需要的,可以将其删除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM