使用的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应用程序开发环境**:包括但不限于Eclipse(虽然现在更推荐使用Android Studio)、Java JDK、Android SDK以及ADT插件等。 **环境变量配置**:安装完成后,需将Android NDK的路径添加到系统的环境...
1. **Android SDK**:Android软件开发工具包是开发Android应用的基础,包括了Java编译器、模拟器、Android平台版本以及各种开发工具,如Android Studio。 2. **Android Studio**:作为官方集成开发环境(IDE),...
这个压缩包的“NDK学习笔记”可能涵盖了这些内容,包括如何设置开发环境、创建和调用本地方法、处理不同类型的数据(如数组、对象等)、以及在Android中使用NDK的特定细节,如Android.mk或CMakeLists.txt构建文件的...
在 Android 开发中,Clang 可以作为 NDK 的一部分用于编译 C/C++ 代码。 #### HTML5 新特性 - **离线存储**:通过 Application Cache API,可以让网页应用在没有网络连接的情况下也能正常运行; - **拖放功能**:...
在安装过程中,需要注意选择合适的组件和版本,确保包含Android SDK和NDK,以便于进行安卓开发。配置阶段,需要设置好开发环境,包括JDK路径、Android SDK路径以及设备模拟器或连接的真机设备。 接下来是“Delphi ...