使用的AndroidStudio版本是1.3.2,可以支持自动构建NDK,需要做一些配置:
1.工程的local.properties里添加ndk路径:
## This file is automatically generated by Android Studio. # Do not modify this file -- YOUR CHANGES WILL BE ERASED! # # This file must *NOT* be checked into Version Control Systems, # as it contains information specific to your local configuration. # # Location of the SDK. This is only used by Gradle. # For customization when using a Version Control System, please read the # header note. #Tue Sep 15 17:59:20 CST 2015 ndk.dir=/Users/songjia/software/android-ndk-r10e sdk.dir=/Users/songjia/software/android-sdk
2.在需要使用本地代码的模块中添加jni目录和需要的源文件,头文件;
不需要再手动编写Android.mk编译文件,会自动生成的。
3.在模块的build.gradle中添加ndk配置项:
apply plugin: 'com.android.library' android { compileSdkVersion 22 buildToolsVersion "23.0.0" defaultConfig { minSdkVersion 14 targetSdkVersion 22 versionCode 1 versionName "1.0" ndk{ //模块名 moduleName 'ndkdemo' //目标平台 abiFilters 'armeabi','armeabi-v7a' //链接库文件 ldLibs 'log' } } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) }
4.新版AndroidStudio要在项目的gradle.properties添加一句 :
# Project-wide Gradle settings. # IDE (e.g. Android Studio) users: # Gradle settings configured through the IDE *will override* # any settings specified in this file. # For more details on how to configure your build environment visit # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. # Default value: -Xmx10248m -XX:MaxPermSize=256m # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true # 使用废弃的NDK android.useDeprecatedNdk=true
没有报错的话就可以编译成功了
相关推荐
Android Studio中使用NDK/JNI 的相关代码http://blog.csdn.net/jfzl123/article/details/53436600
Android Studio 中使用ndk 开发
在AndroidStudio下配置NDK,生成so文件的方法,依照示例即可
Mac下的AndroidStudio的NDK配置及开发示例
android studio中使用ndk编译.so文件,调用C/C++代码(jni编程)
个人认为使用Android Studio作NDK开发是必然趋势,所以本文将简单介绍如何在Android Studio上实现NDK开发。 简介 JNI JNI 是Java Native Inteface的缩写,是Java中定义的一种用于连接Java和C/C++接口的一种实现方式...
Android Studio JNI/NDK 编程; 具体见博客: http://blog.csdn.net/q610098308/article/details/51313341
让我们来学习如何使用Android Studio 1.3搞NDK吧~.zip,使用android studio的android ndk示例
android studio 2.2.2 和NDK12R,开发NDK的利器,使用方法可以参考我的博客
Android Studio环境下如何进行ndk开发
Android基础——Android Studio2.1配置NDK运行HelloWord
AndroidStudio中 NDK开发,动态so库
文档主要用于帮助Android开发中NDK放开方面的新手写的文档,在于指导开发者配置NDK开发环境以及快捷方式等。
How to create a c++ library with NDK on Android Studio 1.5 (not experimental way),视频教程。
AndroidStudio给现有的项目添加NDK支持; 详情可以参考:Android Studio NDK开发-现有项目添加NDK开发(https://blog.csdn.net/niuba123456/article/details/81050052)
android studio cmake android ndk-jni动态库开发,这个可以在cmake下链接生成多个so库
Android studio 下 NDK Jni 开发 简单demo 谢谢
使用Android Studio + NDK进行JNI开发,博客中有详尽说明,可以参考 http://blog.csdn.net/u014316982/article/details/53081597