在eclipse里配置Android ndk环境 适用于windows mac 和linux(转)
由于做Android在底层有库的时候需要交叉编译环境,c代码需要用ndk-build来进行编译,而java代码则需要用Android sdk编译。之前由于对eclipse ide不太熟悉,所以往往编译的时候都是在记事本里写好c代码,然后用cygwin搭建ndk-build环境,用ndk-build来编译出相关的so 之后再用eclipse里去编译java程序,从而使用该so。
其实并不用这么复杂,利用eclipse完全可以达到编译so的目的
点击project->builders->new->Program

然后选择Location
在windows下为
D:\Android\ndk\ndk\ndk-r7-windows\ndk-build.cmd
在linux和mac下为可执行的ndk-build路径
然后选择
Working Directory
D:\Android\ndk\ndk\android-ndk-r6b\samples\<your jni project name>
选择到您对应的jni路径,然后在我们编译运行的时候,这个builder就会自动地去编译so库,而sdk会去编译java代码,实现利用eclipse实现交叉编译
如果还有疑问,可以看这篇文章
http://mobilepearls.com/labs/ndk-builder-in-eclipse/
Setting up Automatic NDK Builds in Eclipse
When editing native JNI code in an Android project using the Android NDK you may configure Eclipse to automatically rebuild your project when editing native code, just
as it does for java. The below steps shows how to perform the necessary configuration (note that this requires revision 4 or later of the NDK – previous revisions does not contain the necessary ndk-build binary):
Start by right clicking on your android project (named hello-neon in the below screenshots) with JNI resources, and select Properties. In the resulting dialog, choose the Builders entry in the list to the left and press the New... button:

A new dialog will open presenting a list of builder types. Select the Program type and press the OK button:

In the Main tab, fill in the following:
- Name:
- NDK Builder
- Location:
- /opt/android-ndk/ndk-build (or wherever your ndk-build binary is). You may use a variable as in ${system_property:user.home}/lib/android-ndk/ndk-build
- Working Directory:
- ${workspace_loc:/hello-neon} (replace hello-neon with your project name. Press the
Browse Workspace...button to select it graphically)
The result should look something like the below:

Now continue with the refresh tab. Make sure the two checkboxes Refresh resources upon completion. and Recursively include sub-foldersare checked. Choose the Specific resources radio button and press the Specify button:
Resources...

Since the ndk-build process will generate files in the lib folder, we want Eclipse to discover changes made there without having to refresh manually. So select the lib folder in the project (create one if necessary) and press the Finish button:

Now skip the Environment tab and go to the final Build Options tab. Make sure the Run the builder: During auto builds checkbox is checked.

Since the NDK build only needs to happen when editing files in the jni folder, check that folder and press the Finish button.

Now finally press OK in the builder configuration dialog – the new NDK builder should now be up and running. Try editing any file in the jni folder and check that the Console view produces output from the build process:

Contact support@mobilepearls.com for feedback
在eclipse里配置Android ndk环境 适用于windows mac 和linux(转)的更多相关文章
- eclipse里配置Android ndk环境,用eclipse编译.so文件
做Android NDK开发时,c代码需要用ndk-build来进行编译,而java代码则需要用Android sdk编译. 编译c代码有两种方法: 一.写好c代码后,然后用cygwin搭建ndk-b ...
- 在eclipse中配置android ndk的自动编译环境builders
无论linux还是mac在jni目录中直接运行 ndk-build 就可以生成 lib目录及所需要的 so文件: windows 装上lnx模拟器也是一样: 每次修改完 c++代码, 都要运行一下 ...
- 在Eclipse下搭建Android开发环境教程
我们昨天向各位介绍了<在NetBeans上搭建Android SDK环境>,前不久也介绍过<在MyEclipse 8.6上搭建Android开发环境>, 都受到了读者的欢迎.但 ...
- Ubuntu配置Android编译环境
1.Ubuntu安装 VMware安装ubuntu之后,安装Vmware tools: 1.安装完ubuntu后,VMware Workstation菜单:虚拟机-->安装 Vmware Too ...
- Windows XP环境下 搭建Android NDK环境
搭建Android NDK环境 Windows XP环境下 1 一些下载 ① NDK r7:http://developer.android.com/sdk/ndk/index.html ② cygw ...
- 【转】在Eclipse下搭建Android开发环境教程
本文将全程演示Android开发环境的搭建过程,无需配置环境变量.所有软件都是写该文章时最新版本,希望大家喜欢. 一 相关下载 三 Eclipse配置 (1)Java JDK下载 1 安装andr ...
- ubuntu配置android开发环境和编译源码遇到的一些问题
---------------------------------------------环境变量设置--------------------------------------------- 1.设 ...
- Android开发:修改eclipse里的Android虚拟机路径
一.发现问题: 今天打开电脑发现C盘缩了不少,这才意识到:eclipse里配置的安卓虚拟机默认放在了C盘里. 当然,在不同的电脑上可能路径有所不同,我的默认路径是:C:\Users\lenovo\.a ...
- Ubuntu Linux下如何配置Android开发环境
下载和安装Win7系统Android开发环境中讲了怎样在Win7系统中安装Android开发环境,那么怎样在Linux系统中配置Android开发环境呢?本篇文章就将演示如何使用Eclipse.And ...
随机推荐
- Window7 Cocos2d-x配置开发环境
1.到Cocos2d-x官方网下载最新版,解压后在目录cocos2d-x-2.1.5\tools\project-creator\create_project.py 2.安装Python,到网站htt ...
- c数组
一维数组 有三种赋值方式 1.原始的赋值 2. 初始化赋值 3.动态赋值 数组的花式玩法 void main() { ] = {, , , , , , , , , }; test(a); putcha ...
- c# 生成随机时间
Random random = new Random((int)(DateTime.Now.Ticks)); ; ) { , ); , ); , ); string tempStr = string. ...
- 嵌入式开发之hisilicon---hi3536 处理器简介
(1)处理器概述 (2)处理器模块架构 --------------author:pkf -------------------time:7-19 -------------------------- ...
- (转)TCP连接异常断开检测
TCP是一种面向连接的协议,连接的建立和断开需要通过收发相应的分节来实现.某些时候,由于网络的故障或是一方主机的突然崩溃而另一方无法检测到,以致始终保持着不存在的连接.下面介绍一种方法来检测这种异常断 ...
- android 解决输入法键盘遮盖布局问题
/** * @param root 最外层布局,需要调整的布局 * @param scrollToView 被键盘遮挡的scrollToView,滚动root,使scrollToVie ...
- mybatis plus 联合查询
在xml中只需要需要写如下的代码即可实现分页: <select id="selectUserList" parameterType="map" resul ...
- Saltstack配置管理(2)
1.SaltStack批量安装zabbix_agent端. vim /etc/salt/states/init/zabbix_agnet.sls zabbix_install.conf: pkg.in ...
- Spring Cloud 微服务的那点事
什么是微服务 微服务的概念源于2014年3月Martin Fowler所写的一篇文章“Microservices”. 微服务架构是一种架构模式,它提倡将单一应用程序划分成一组小的服务,服务之间互相协调 ...
- Dubbo简介2
Dubbo是阿里巴巴公司开源的一个高性能优秀的服务框架,使得应用可通过高性能的 RPC 实现服务的输出和输入功能,可以和Spring框架无缝集成.具体可以看 百度百科 https://baike.ba ...