Integrating .so files into your APK

With the recent changes (release 0.7.3 around Dec 27), the new Android Build System starts to be really interesting also if you are using the NDK!

0.7.2:Add jniLibs folder to source sets for prebuilt .so files.

Now this is really easy to integrate native libraries in your package and generate APKs for different architectures while correctly handling version codes (for more information on why this may be important, please refer to my first article).

If you are using Android Studio and need to integrate native libraries in your app, you may have had to use some complex methods before, involving maven and .aar/.jar packages… the good news is you don’t need these anymore 

You only need to put your .so libraries inside the jniLibs folder under sub-directories named against each supported ABI (x86, mips, armeabi-v7a, armeabi), and that’s it !

Once it’s done, all the .so files will be integrated into your apk when you build it:

If the jniLibs folder name doesn’t suit you (you may generate your .so files somewhere else), you can set a specific location in build.gradle:

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

Via: http://ph0b.com/android-studio-gradle-and-ndk-integration/

时间: 2024-11-06 17:12:25

Integrating .so files into your APK的相关文章

Android Duplicate files copied in APK

今天调试 Android 应用遇到这么个问题: Duplicate files copied in APK META-INF/DEPENDENCIES File 1: httpmime-4.3.2.jar File 2: httpmime-4.3.2.jar 貌似说两个包里面的文件重复了还是怎么的,谷歌了一番之后据说应该是 android studio 自身的bug 解决办法: 打开项目下面的 build.gradle 文件,在 android 代码块中添加下面代码 android { pack

Android Studio - Gradle 更新升级到2.1.0后,发生Duplicate files copied in APK META-INF

今天升级了Android Studio到2.1正式版,发现其建议更新Gradle版本,于是把Gradle更新到2.1.0,但是更新后项目无法跑,报错:Duplicate files copied in APK META-INF. 之前项目也有遇到同样的问题,只需要在app项目中(我的项目有几个子module)添加以下代码就可以了: packagingOptions { exclude 'META-INF/LICENSE.txt' exclude 'META-INF/LICENSE' exclud

Android学习笔记--遇到Duplicate files copied in APK META-INF/LICENSE.txt

在修改老的项目中遇到的此问题,导入jar包的时候报 Error:Execution failed for task ':ADApplication:transformResourcesWithMergeJavaResForDebug'.> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied i

Android Studio 错误 Duplicate files copied in APK META-INF/LICENSE.txt

1 .Duplicate files copied in APK META-INF/LICENSE.txt android { packagingOptions { exclude 'META-INF/LICENSE.txt' } } My logcat: log Execution failed for task ':Prog:packageDebug'. Duplicate files copied in APK META-INF/LICENSE.txt File 1: /home/scij

Duplicate files copied in APK META-INF/LICENSE.txt

Error:Execution failed for task ':app:packageDebug'. > Duplicate files copied in APK META-INF/LICENSE.txt File 1: /Users/weichunsheng/.gradle/caches/modules-2/files-2.1/commons-cli/commons-cli/1.2/2bf96b7aa8b611c177d329452af1dc933e14501c/commons-cli-

Duplicate files copied in APK META-INF/LICENSE 编译失败解决方法

# 错误日志> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE File1: /Users/xulun/Downloads/android 2/app/libs/httpclient-4.5.3.jar File2: /Users/xulun

if the parser found inconsistent certificates on the files in the .apk.104

当静默安装提示104时,是说升级的APK 和本地已经安装的APK 签名不一致,所以无法升级. 经百度,找到知乎同学@陈子腾的回答,找到了问题所在. 可以比对apk签名的fingerprint. 假定安装了JDK,如果想查HelloWorld.apk所使用的签名的fingerprint,可以这样做: 1. 查找apk里的rsa文件 (Windows)> jar tf HelloWorld.apk |findstr RSA (Linux)$ jar tf HelloWorld.apk |grep R

as项目导入异常"duplicate files copied in apk meta-inf/maven/*"

在导入philm项目的时候出现了上面的错误.最后在stackoverflow上找到了解决方法 解决方法:在build.gradle的Android界面下添加 packagingOptions { exclude 'META-INF/maven/com.squareup.okhttp/okhttp/pom.xml' exclude 'META-INF/maven/com.squareup.okhttp/okhttp/pom.properties' exclude 'META-INF/maven/c

android studio(AS) Duplicate files copied in APK META-INF/NOTICE.txt

File 1: /home/slava/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpmime/4.3.1/f7899276dddd01d8a42ecfe27e7031fcf9824422/httpmime-4.3.1.jar File 2: /home/slava/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpmime/4.3.