很久以后,Android Gradle插件0.7.3中添加了在Android项目中添加预先构建的.so文件的支持。但与我不同的是,很多人仍在使用hack / workaround添加预先构建的.so文件,即使用某个层次结构压缩文件,然后重命名为.jar。以下是如何正确添加.so文件的分步指南。
答案 0 :(得分:21)
那么如何添加预先构建的.so文件?
1)将你的android studio升级到0.4.0
2)将gradle-wrapper.properties中的“distributionUrl =”替换为“distributionUrl = http://services.gradle.org/distributions/gradle-1.9-all.zip”
3)使用:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.3'
}
}
4)
5)在build.gradle中添加以下内容:
android {
compileSdkVersion 18
buildToolsVersion "18.1.0"
defaultConfig {
minSdkVersion 10
targetSdkVersion 18
}
productFlavors {
x86 {
ndk {
abiFilter "x86"
}
}
arm {
ndk {
abiFilters "armeabi-v7a", "armeabi"
}
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/notice.txt'
}
}
6)建立你的项目。
答案 1 :(得分:1)
我终于实现了这段代码..
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.3'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
}
productFlavors {
x86 {
ndk {
abiFilter "x86"
}
}
arm {
ndk {
abiFilters "armeabi-v7a", "armeabi"
}
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/notice.txt'
}
}