Gradle Android不支持NDK构建[gradle migration from 0.12。+ tot 1.1]

时间:2015-03-23 06:24:50

标签: android android-studio gradle android-ndk

我最近从Android Studio 0.9+迁移到1. +,我必须将我的gradle版本从0.12。+更改为1.1。+以满足IDE要求。我的app和jni正在运行 我的build.gradle文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 20
    buildToolsVersion '20.0.0'

    defaultConfig {
        applicationId "..."
        minSdkVersion 17
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
        ndk {
            moduleName "behagcoder"
            cFlags "-DHAVE_CONFIG_H -DFPM_ARM -ffast-math -O3"   // Define some macros
            ldLibs "android", "log"       // Link with these libraries!
            stl "stlport_shared"
        }

    }
    //flavorDimensions "abi"

    productFlavors {
        x86 {
            flavorDimension "x86"
            ndk {
                abiFilter "x86"
            }
        }
        mips {
            ndk {
                abiFilter "mips"
            }
        }
        arm {
            flavorDimension "abi"
            ndk {
                abiFilter "armeabi"
                moduleName "behagcoder"
                cFlags "-DHAVE_CONFIG_H -DFPM_ARM -ffast-math -O3"   // Define some macros
                ldLibs "android", "log"       // Link with these libraries!
                stl "stlport_shared"
            }

        }
        armv7 {
            flavorDimension "abi"

            ndk {
                abiFilter "armeabi-v7a"
            }
        }
    }
    sourceSets.main {
        jni.srcDirs = [] // This prevents the auto generation of Android.mk
        jniLibs.srcDir 'src/main/libs'
    }
    task buildNative(type: Exec, description: 'Compile JNI source via NDK') {
        def ndkDir = "/home/shad/Downloads/NDK/android-ndk-r10d"
        commandLine "$ndkDir/ndk-build",
                '-C', file('src/main/jni').absolutePath,
                '-j', Runtime.runtime.availableProcessors(),
                'all',
                'NDK_DEBUG=1'
    }
    task cleanNative(type: Exec, description: 'Clean JNI object files') {
        def ndkDir = "/home/shad/Downloads/NDK/android-ndk-r10d"
        commandLine "$ndkDir/ndk-build",
                '-C', file('src/main/jni').absolutePath,
                'clean'
    }

    clean.dependsOn 'cleanNative'

    tasks.withType(JavaCompile) {
        compileTask -> compileTask.dependsOn buildNative
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    ...
}

我的Android.mk文件

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := behagcoder
LOCAL_ARM_MODE  := arm
LOCAL_SRC_FILES := NativeSRLDecoder.cpp bhg/bit.c bhg/decoder.c bhg/fixed.c bhg/frame.c bhg/huffman.c bhg/layer3.c bhg/stream.c bhg/synth.c bhg/timer.c bhg/version.c
LOCAL_CFLAGS    := -DHAVE_CONFIG_H -DFPM_ARM -ffast-math -O3
# for logging
LOCAL_LDLIBS += -llog
# for local asset manger
#LOCAL_LDLIBS += -landroid

include $(BUILD_SHARED_LIBRARY)

错误:

  

java.lang.UnsatisfiedLinkError:找不到本机方法:

我是Android开发的新手,我也想为x86,mips等多处理器类型构建应用程序。提前感谢

0 个答案:

没有答案