ndk - Experimental Gradle - 如何添加本地LDLib?

时间:2016-05-10 00:08:30

标签: android gradle android-ndk gradle-plugin

我的项目有一些预建的库和jni源。使用以下Android.mk构建它们可以正常工作。

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := arcade

LOCAL_C_INCLUDES += $(LOCAL_PATH)/include

LOCAL_SRC_FILES := torchdemo.cpp torchandroid.cpp android_fopen.c

LOCAL_LDLIBS := -llog -landroid -L$(LOCAL_PATH)/prebuilts -lluaT - lluajit -lTH  -lTHNN  -ltorch -lnnx -limage -ltorchandroid 


include $(BUILD_SHARED_LIBRARY)`

这是我的build.gradle

model {

    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.2"

        ndk {
            moduleName "arcade"
            ldLibs.addAll(["android", "log"])

        }

        defaultConfig {
            minSdkVersion.apiLevel 16
            targetSdkVersion.apiLevel 23
            versionCode 1
            versionName "1.0"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles.add(file("proguard-rules.pro"))
            }
        }


    }

    android.sources {

        main {
            jniLibs {
                source {
                    srcDirs 'src/main/libs'
                }
            }
        }

        main {
            jni {
                exportedHeaders {
                    srcDir "src/main/jni/include"
                }
            }
        }
    }

}

使用gradle构建会导致未定义引用的链接器错误,因为gradle没有添加预构建的库。如何将ldlibs标志添加到gradle中的本地预构建库?

0 个答案:

没有答案