介绍
本文主要介绍Android studio 2.x中Jni开发的主要配置。
配置方法
将classpath 设置为 classpath 'com.android.tools.build:gradle-experimental:0.7.2'
将distributionUrl 设置为 distributionUrl=https://services.gradle.org/distributions/gradle-2.10-all.zip
gradle.properties文件中添加一行:android.useDeprecatedNdk=true
local.properties文件中添加ndk路径:ndk.dir=D:\NDK\android-ndk-r10e
在src/main下创建jni文件夹
build.gradle文件更改改为(只是参考,具体根据自己项目设置):
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "me.pkhope.picturepro"
minSdkVersion.apiLevel 14
targetSdkVersion.apiLevel 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles.add(file('proguard-android.txt')) }
}
ndk {
moduleName "JniTest"
ldLibs.addAll("jnigraphics") //使用Bitmap需添加
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
}