Android studio 中调用ndk-build 进行编译native 层直接编译

修改build.gradle 文件
 
  
 
  
android {
    compileSdkVersion 12
    buildToolsVersion "25.0.3"

    defaultConfig {
        applicationId "org.libsdl.app"
        minSdkVersion 10
        targetSdkVersion 12

        ndk {
            moduleName "SDL2"
            abiFilters "armeabi", "armeabi-v7a", "arm64-v8a"
        }
    }
    sourceSets.main {
        jniLibs.srcDir 'libs'
        jni.srcDirs = []
    }

    externalNativeBuild {
        ndkBuild{
            path "src/main/jni/Android.mk"
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

其中ndkBuild path路径是以 build.gradle 所在路径的相对路径,指向ndk-build jni目录对应的Android.mk
 
 

你可能感兴趣的:(Android)