I understand this is asked many times, but I have done thorough research before posting my query.
我知道这被问了很多次,但是我在发布我的查询之前做了深入的研究。
I have updated Android Studio to latest version as of March 2nd 2015, version 1.1.0. I think still grade does not package .so files on its own.
我已经更新了Android Studio到2015年3月2日的最新版本,版本1.1.0。我认为还是分数不包,所以文件是自己的。
I have written NewNDK.c in /jni folder. Ran the ndk-build script and .so files were created in /libs. As per suggestion in one of the posts, I modified libs to lib.
我写了NewNDK。c / jni文件夹中。运行ndk-build脚本,并在/libs中创建文件。根据其中一篇文章的建议,我将libs修改为lib。
Even then, I am getting java.lang.UnsatisfiedLinkError: Couldn't load from loader dalvik.system.PathClassLoader findLibrary returned null error.
即使这样,我也得到了java.lang。不满意链接错误:无法从加载器dalvik.system加载。路径类加载器findLibrary返回零错误。
The posts does not say about which files to modify. I am new to Android, request your help.
文章没有说明要修改哪些文件。我是Android的新手,请求你的帮助。
I have narrowed down the problem to: 1. Gradle is not packaging 2. Gradle scripts should be modified.
我已经把问题缩小到:1。Gradle不是包装2。应该修改Gradle脚本。
The build.gradle (Module: app) is as below:
构建。gradle(模块:app)如下:
apply plugin: 'com.android.application'
应用插件:“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'
}
The build.gradle (project) is as below:
构建。等级(项目)如下:
// 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()
}
}
Please let me know what is missing.
请让我知道缺少什么。
Thank You!
谢谢你!
2 个解决方案
#1
3
As per suggestion in one of the posts, I modified libs to lib.
根据其中一篇文章的建议,我将libs修改为lib。
It doesn't really make sense to do that. lib
is the folder where your .so files will go inside the APK, but this step will be handled directly by the packaging tools if your project is correctly organized.
这样做没有意义。lib是你的文件夹,所以文件会进入APK,但是如果你的项目是正确的组织,这个步骤将被打包工具直接处理。
Inside an Android Studio project, you should put the .so files inside jniLibs/<ABI>
where <ABI>
is the target architecture of each .so file (armeabi, x86... the same way that they are generated from the NDK inside libs).
在一个Android Studio项目中,你应该把so文件放在jniLibs/
So you can either rename your libs
folder to jniLibs
, or configure your build so your .so files from libs
will be directly integrated:
因此,您可以将libs文件夹重命名为jniLibs,也可以将您的构建配置为您的构建。因此,libs中的文件将直接集成:
android {
...
sourceSets.main {
jniLibs.srcDir 'src/main/libs'
}
}
#2
0
Open the project properties > go to Andriod options > select Advance tab > just uncheck "armeabi","armeabi-v7a","arm64-v8a" and save the project.
打开项目属性>到Andriod选项>选择Advance tab >只是取消“armeabi”,“armeabi-v7a”,“arm64-v8a”并保存项目。
The Error will be removed.
错误将被删除。
#1
3
As per suggestion in one of the posts, I modified libs to lib.
根据其中一篇文章的建议,我将libs修改为lib。
It doesn't really make sense to do that. lib
is the folder where your .so files will go inside the APK, but this step will be handled directly by the packaging tools if your project is correctly organized.
这样做没有意义。lib是你的文件夹,所以文件会进入APK,但是如果你的项目是正确的组织,这个步骤将被打包工具直接处理。
Inside an Android Studio project, you should put the .so files inside jniLibs/<ABI>
where <ABI>
is the target architecture of each .so file (armeabi, x86... the same way that they are generated from the NDK inside libs).
在一个Android Studio项目中,你应该把so文件放在jniLibs/
So you can either rename your libs
folder to jniLibs
, or configure your build so your .so files from libs
will be directly integrated:
因此,您可以将libs文件夹重命名为jniLibs,也可以将您的构建配置为您的构建。因此,libs中的文件将直接集成:
android {
...
sourceSets.main {
jniLibs.srcDir 'src/main/libs'
}
}
#2
0
Open the project properties > go to Andriod options > select Advance tab > just uncheck "armeabi","armeabi-v7a","arm64-v8a" and save the project.
打开项目属性>到Andriod选项>选择Advance tab >只是取消“armeabi”,“armeabi-v7a”,“arm64-v8a”并保存项目。
The Error will be removed.
错误将被删除。