使用 Android Gradle 插件 0.7.3 在项目中添加预构建的 .so 文件 [英] Add pre-built .so files in project using Android Gradle plugin 0.7.3

查看:26
本文介绍了使用 Android Gradle 插件 0.7.3 在项目中添加预构建的 .so 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很长一段时间后,Android Gradle 插件 0.7.3 中添加了在 Android 项目中添加预构建 .so 文件的支持.但与我不同的是,很多人仍在使用 hack/workaround 添​​加预先构建的 .so 文件,即使用特定层次结构压缩文件,然后重命名为 .jar.以下是有关如何正确添加 .so 文件的分步指南.

Well after a long time the support to add pre-built .so files in an Android project has been added in Android Gradle plugin 0.7.3. But unlike me a lot of people are still using the hack/workaround to add pre-built .so files, i.e zip the files using a certain hierarchy and then re-name into a .jar. Below is a step by step guide to how to properly add .so files.

推荐答案

那么如何添加预构建的 .so 文件?

So how you can add the pre-built .so files ?

1) 将您的 android studio 升级到 0.4.0
2) 将 gradle-wrapper.properties 中的distributionUrl="替换为distributionUrl=http://services.gradle.org/distributions/gradle-1.9-all.zip"
3)添加/替换你的buildscript"部分build.gradle:

1) Upgrade your android studio to 0.4.0
2) Replace "distributionUrl=" in gradle-wrapper.properties with "distributionUrl=http://services.gradle.org/distributions/gradle-1.9-all.zip"
3) Add/Replace your 'buildscript' section build.gradle with:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.7.3'
    }
} 

4)

5) 在 build.gradle 中添加以下内容:

5) Add the following in your 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) 构建您的项目.

这篇关于使用 Android Gradle 插件 0.7.3 在项目中添加预构建的 .so 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆