当前位置:天才代写 > tutorial > 安卓教程 > Android studio 配置JNI环境

Android studio 配置JNI环境

2021-02-08 10:17 星期一 所属: 安卓教程 浏览:919

Android studio配备jni开发工具,关键配备是2个build文档,及其新创建一个jni文档,放c编码。

 

编码以下1:

apply plugin: 'com.android.model.application'

model {
    android {
        compileSdkVersion = 23
        buildToolsVersion = "23.0.2"

        defaultConfig.with {
            applicationId = "me.chunsheng.jni"
            minSdkVersion.apiLevel = 9
            targetSdkVersion.apiLevel = 23
        }

    }


    /*
 * native build settings
 */
    android.ndk {
        moduleName = "hello-world"
        /*
    moduleName = "hello-jni"
     * Other ndk flags configurable here are
     * cppFlags.add("-fno-rtti")
     * cppFlags.add("-fno-exceptions")
     * ldLibs.addAll(["android", "log"])
     * stl       = "system"
     */
    }

    android.buildTypes {
        release {
            minifyEnabled = false
            multiDexEnabled = true
            proguardFiles.add(file("proguard-rules.pro"))
        }
    }


    android.productFlavors {
        // for detailed abiFilter descriptions, refer to "Supported ABIs" @
        // https://developer.android.com/ndk/guides/abis.html#sa
        create("arm") {
            ndk.abiFilters.add("armeabi")
        }
        create("arm7") {
            ndk.abiFilters.add("armeabi-v7a")
        }
        create("arm8") {
            ndk.abiFilters.add("arm64-v8a")
        }
        create("x86") {
            ndk.abiFilters.add("x86")
        }
        create("x86-64") {
            ndk.abiFilters.add("x86_64")
        }
        create("mips") {
            ndk.abiFilters.add("mips")
        }
        create("mips-64") {
            ndk.abiFilters.add("mips64")
        }
        // To include all cpu architectures, leaves abiFilters empty
        create("all")
    }

}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.2.0'
}

 

编码以下2:

 

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle-experimental:0.4.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

 

立即编译程序,运作就可以启用c编码了,此次Android studio版本号 2.0—beta 7.及其环境变量如上。

 

 

因为版本升级,gradle的英语的语法的更改,build文档很有可能会产生变化,時刻关心官方网站 

 

http://tools.android.com/tech-docs/new-build-system/gradle-experimental#TOC-0.2.x—0.4.0

 

    关键字:

天才代写-代写联系方式