Android Studio抱怨缺少JNI类
为什么我的Android Studio找不到相关的JNI类 我在一个名为Android Studio抱怨缺少JNI类,android,android-studio,android-ndk,java-native-interface,android-studio-3.0,Android,Android Studio,Android Ndk,Java Native Interface,Android Studio 3.0,为什么我的Android Studio找不到相关的JNI类 我在一个名为opensslSign的异步任务中有一个类,它与jni.so文件libcryptowrapper.so相关。构建工作正常,但Android Studio抱怨:“无法解析相应的JNI函数”。我已经将我的.so文件移动到多个文件夹中,只是想看看Android是否找到了它,但运气不好 Android Studio能够在.so文件和JNI类目录(包含Android.mk)中找到JNI类 我的格拉德尔: // Top-level bu
opensslSign
的异步任务中有一个类,它与jni
.so
文件libcryptowrapper.so
相关。构建工作正常,但Android Studio抱怨:“无法解析相应的JNI函数”。我已经将我的.so
文件移动到多个文件夹中,只是想看看Android是否找到了它,但运气不好
Android Studio能够在.so
文件和JNI
类目录(包含Android.mk
)中找到JNI类
我的格拉德尔:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
apply plugin: 'com.android.application'
dependencies {
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:25.0.0'
compile fileTree(dir: 'libs', include: '*.so')
compile fileTree(dir: 'lib', include: '*.jar')
compile(name:'google-maps-sdk-m4b', ext:'aar')
compile(project(':deps:android-map-utils:library')) {
exclude group: 'com.android.support', module: 'support-v4'
}
compile 'com.google.android.gms:play-services:11.0.4'
compile "com.google.android.gms:play-services-location:11.0.4"
compile group: 'org.apache.james', name: 'apache-mime4j', version: '0.6'
compile group: 'commons-codec', name: 'commons-codec', version: '1.10'
compile group: 'commons-io', name: 'commons-io', version: '2.5'
compile group: 'net.lingala.zip4j', name: 'zip4j', version: '1.3.2'
compile group: 'net.sf.kxml', name: 'kxml2', version: '2.3.0'
compile group: 'net.sf.opencsv', name: 'opencsv', version: '2.3'
compile group: 'joda-time', name: 'joda-time', version: '2.9.5'
}
android {
compileSdkVersion 24
buildToolsVersion '25.0.0'
useLibrary 'org.apache.http.legacy'
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude 'jsr305_annotations/Jsr305_annotations.gwt.xml'
exclude 'build-data.properties'
}
defaultConfig {
// Already hit dex limit
multiDexEnabled true
dexOptions {
javaMaxHeapSize "4g"
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
lintOptions {
abortOnError false
}
splits {
abi {
enable true
reset()
include 'x86', 'armeabi-v7a'
universalApk true
}
}
}
repositories {
flatDir{
dirs 'libs'
}
}
allprojects {
repositories {
jcenter()
}
}
//顶级生成文件,您可以在其中添加所有子项目/模块通用的配置选项。
构建脚本{
存储库{
jcenter()
}
依赖关系{
classpath'com.android.tools.build:gradle:2.3.3'
}
}
应用插件:“com.android.application”
依赖关系{
编译'com.android.support:multidex:1.0.1'
编译'com.android.support:appcompat-v7:25.0.0'
编译文件树(目录:“libs”,包括:“*.so”)
编译文件树(目录:“lib”,包括:“*.jar”)
编译(名称:'google-maps-sdk-m4b',分机:'aar')
编译(项目(':deps:android-map-utils:library')){
排除组:“com.android.support”,模块:“support-v4”
}
编译'com.google.android.gms:play services:11.0.4'
编译“com.google.android.gms:播放服务位置:11.0.4”
编译组:“org.apache.james”,名称:“apache-mime4j”,版本:“0.6”
编译组:“commons codec”,名称:“commons codec”,版本:“1.10”
编译组:“commons io”,名称:“commons io”,版本:“2.5”
编译组:“net.lingala.zip4j”,名称:“zip4j”,版本:“1.3.2”
编译组:“net.sf.kxml”,名称:“kxml2”,版本:“2.3.0”
编译组:“net.sf.opencsv”,名称:“opencsv”,版本:“2.3”
编译组:“joda time”,名称:“joda time”,版本:“2.9.5”
}
安卓{
编译DK24版
buildToolsVersion“25.0.0”
useLibrary'org.apache.http.legacy'
包装选项{
排除“META-INF/依赖项”
排除“META-INF/许可证”
排除“META-INF/LICENSE.txt”
排除“META-INF/license.txt”
排除“META-INF/通知”
排除“META-INF/NOTICE.txt”
排除“META-INF/notice.txt”
排除“META-INF/ASL2.0”
排除'jsr305_annotations/jsr305_annotations.gwt.xml'
排除“生成数据.属性”
}
默认配置{
//已经达到了极限
多索引启用真
德克斯选项{
javaMaxHeapSize“4g”
}
}
源集{
主要{
manifest.src文件“AndroidManifest.xml”
java.srcDirs=['src']
aidl.srcDirs=['src']
renderscript.srcDirs=['src']
res.srcDirs=['res']
assets.srcDirs=['assets']
jniLibs.srcDirs=['libs']
}
//将测试移动到tests/java、tests/res等。。。
instrumentTest.setRoot('tests'))
//将生成类型移动到生成类型/
//例如,build-types/debug/java、build-types/debug/AndroidManifest.xml。。。
//这会将它们移出src/…下的默认位置,这将
//与主源集正在使用的src/冲突。
//应同时添加新的构建类型或产品风格
//通过类似的定制。
setRoot('build-types/debug')
setRoot('build-types/release')
}
林特选项{
异常错误
}
分裂{
阿比{
启用真
重置()
包括“x86”、“armeabi-v7a”
宇宙真实
}
}
}
存储库{
弗拉蒂尔{
dirs'libs'
}
}
所有项目{
存储库{
jcenter()
}
}
删除
拆分{
阿比{
启用真
重置()
包括“x86”、“armeabi-v7a”
宇宙真实
}
}
它现在由Android studio自动管理。谢谢。我已经删除了它,构建仍按预期工作,但Android Studio仍在抱怨链接错误。请阅读,我希望这能回答您的问题这就是我一直在寻找的答案。非常感谢。