如何添加.so文件到一个Android库项目使用摇篮0.7+ [英] How can I add .so files to an android library project using gradle 0.7+

查看:302
本文介绍了如何添加.so文件到一个Android库项目使用摇篮0.7+的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

项目结构:

应用项目 - >依赖于库项目

App project --> depends on Library project

图书馆计划 有一个文件夹编译JNI库

Library Project has a folder for the compiled jni libs

jniLibs.srcDirs = ['libs']

和我试着加入以下的build.gradle为每示例应用程序<一个android的元素href="https://android.googlesource.com/platform/tools/build/+/2e1f7810edd76d92cee8d3e06bc4dec0c288adea/tests/ndkSanAngeles/build.gradle">https://android.googlesource.com/platform/tools/build/+/2e1f7810edd76d92cee8d3e06bc4dec0c288adea/tests/ndkSanAngeles/build.gradle然而,Android的库项目不支持productFlavours,因此在组装失败,无法找到方法productFlavors()的参数[dghdhd]项目

And I've tried adding the following to the android element of the build.gradle as per the example app https://android.googlesource.com/platform/tools/build/+/2e1f7810edd76d92cee8d3e06bc4dec0c288adea/tests/ndkSanAngeles/build.gradle however android library projects do not support productFlavours and as such the assemble fails with "Could not find method productFlavors() for arguments [dghdhd] on project"

productFlavors {
    x86 {
        ndk {
            abiFilter "x86"
        }
    }
    arm {
        ndk {
            abiFilters "armeabi-v7a", "armeabi"
        }
    }
}

有没有办法来添加NDK支持一个Android库项目?

Is there a way to add ndk support to an android library project?

推荐答案

在结束我没有需要使用产品的风味。

In the end I didnt need to use product flavours.

有关库项目我添加以下内容:

For the library project I added the following:

android {
    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
    }        
}

libs文件夹中有一个文件夹,名为armeabi-V7A的,因为这是我唯一的目标,它的工作一种享受。

The libs folder had a folder inside called "armeabi-v7a" and as this is my only target it worked a treat.

NDK的文件(.so)的传播到正在使用的Andr​​oid库项目的Andr​​oid项目。

The ndk files (.so) are propagated into the android project that is using the android library project.

这篇关于如何添加.so文件到一个Android库项目使用摇篮0.7+的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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