如何添加.so文件到一个Android库项目使用摇篮0.7+摇篮、文件、项目、so

由网友(风追烟花雨)分享简介:项目结构:应用项目 - >依赖于库项目App project depends on Library project图书馆计划有一个文件夹编译JNI库Library Project has a folder for the compiled jni libsjniLibs.srcDirs = ['libs...

项目结构:

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

App project --> depends on Library project

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

Library Project has a folder for the compiled jni libs

jniLibs.srcDirs = ['libs']

和我试着加入以下的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.

阅读全文

相关推荐

最新文章