盒子
盒子
文章目录
  1. 2.2之前编译方式:
  2. 2.2之后编译方式:

AndroidStudio2.2之后NDK编译

AndroidStudio更新为2.2之后发现NDK编译出了问题,老是编译不通过,查阅相关资料后发现2.2之后NDK配置方式不太一样了

2.2之前编译方式:

在build.gradle文件中

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
android {
compileSdkVersion ANDROID_BUILD_SDK_VERSION as int
buildToolsVersion ANDROID_BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion ANDROID_BUILD_MIN_SDK_VERSION as int
targetSdkVersion ANDROID_BUILD_TARGET_SDK_VERSION as int
versionCode VERSION_CODE as int
versionName VERSION_NAME
ndk {
moduleName "blur"
cFlags "-DANDROID_NDK -D_RELEASE"
ldLibs "m", "log", "jnigraphics"
abiFilters "all"
}
}
}

然后在gradle.properties文件中添加

1
android.useDeprecatedNdk=true

2.2之后编译方式:

在build.gradle文件中

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
android {
compileSdkVersion ANDROID_BUILD_SDK_VERSION as int
buildToolsVersion ANDROID_BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion ANDROID_BUILD_MIN_SDK_VERSION as int
targetSdkVersion ANDROID_BUILD_TARGET_SDK_VERSION as int
versionCode VERSION_CODE as int
versionName VERSION_NAME
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
ndkBuild {
path file("src/main/jni/Android.mk")
}
}
}

然后导航——>Build——>Make Project即可,会在目录中多出来.externalNativeBuild文件夹

转载请指明出处RobinBlog:http://robinx.net/2016/11/29/AndroidStudio2-2之后NDK编译/