Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android ndk java.lang.UnsatisfiedLinkError:无法从加载程序加载dalvik.system.PathClassLoader findLibrary返回null_Android Ndk - Fatal编程技术网

Android ndk java.lang.UnsatisfiedLinkError:无法从加载程序加载dalvik.system.PathClassLoader findLibrary返回null

Android ndk java.lang.UnsatisfiedLinkError:无法从加载程序加载dalvik.system.PathClassLoader findLibrary返回null,android-ndk,Android Ndk,我知道这个问题被问了很多次,但我在发布我的问题之前已经做了彻底的研究 我已将Android Studio更新至2015年3月2日的最新版本,版本1.1.0。我认为仍然等级不包。所以文件本身 我已经在/jni文件夹中编写了NewNDK.c。运行ndk构建脚本,并在/libs中创建了.so文件。根据其中一篇文章中的建议,我将libs修改为lib 即使如此,我还是得到java.lang.UnsatisfiedLinkError:无法从加载程序dalvik加载。system.PathClassLoade

我知道这个问题被问了很多次,但我在发布我的问题之前已经做了彻底的研究

我已将Android Studio更新至2015年3月2日的最新版本,版本1.1.0。我认为仍然等级不包。所以文件本身

我已经在/jni文件夹中编写了NewNDK.c。运行ndk构建脚本,并在/libs中创建了.so文件。根据其中一篇文章中的建议,我将libs修改为lib

即使如此,我还是得到java.lang.UnsatisfiedLinkError:无法从加载程序dalvik加载。system.PathClassLoader findLibrary返回空错误

帖子没有说明要修改哪些文件。我是Android新手,请求您的帮助

我已把问题缩小到:1。Gradle不是包装2。应该修改渐变脚本

build.gradle模块:应用程序如下:

// 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:1.1.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}
应用插件:“com.android.application”

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.example.raghu.newndk"
        minSdkVersion 17
        targetSdkVersion 17
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
}
build.gradle项目如下所示:

// 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:1.1.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}
请让我知道遗漏了什么

谢谢大家!

根据其中一篇文章中的建议,我将libs修改为lib

这样做真的没有意义。lib是将.so文件放入APK的文件夹,但如果项目组织正确,则此步骤将由打包工具直接处理

在Android Studio项目中,您应该将.so文件放在jniLibs/中,其中是每个.so文件armeabi、x86的目标体系结构。。。与从libs内部的NDK生成它们的方式相同

因此,您可以将libs文件夹重命名为jniLibs,或者配置您的构建,以便直接集成libs中的.So文件:

android {
    ...
    sourceSets.main {
        jniLibs.srcDir 'src/main/libs'
    }
}

打开项目属性>转到Andriod选项>选择高级选项卡>只需取消选中armeabi、armeabi-v7a、arm64-v8a并保存项目

错误将被删除