在eclipse里配置Android ndk环境 适用于windows mac 和linux(转)

2012-02-27 13:02:16|  分类: android |  标签:java  program  android  |举报|字号 订阅

 
 
原文:http://www.migantech.com/blog/codes/2011/11/28/%E5%9C%A8eclipse%E9%87%8C%E9%85%8D%E7%BD%AEandroid-ndk%E7%8E%AF%E5%A2%83-%E9%80%82%E7%94%A8%E4%BA%8Ewindows-mac-%E5%92%8Clinux/

由于做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/

Mobile PearlsLabsSetting up Automatic NDK Builds 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
Resources...
 button:

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(转)的更多相关文章

  1. eclipse里配置Android ndk环境,用eclipse编译.so文件

    做Android NDK开发时,c代码需要用ndk-build来进行编译,而java代码则需要用Android sdk编译. 编译c代码有两种方法: 一.写好c代码后,然后用cygwin搭建ndk-b ...

  2. 在eclipse中配置android ndk的自动编译环境builders

    无论linux还是mac在jni目录中直接运行  ndk-build 就可以生成 lib目录及所需要的 so文件: windows 装上lnx模拟器也是一样: 每次修改完 c++代码, 都要运行一下 ...

  3. 在Eclipse下搭建Android开发环境教程

    我们昨天向各位介绍了<在NetBeans上搭建Android SDK环境>,前不久也介绍过<在MyEclipse 8.6上搭建Android开发环境>, 都受到了读者的欢迎.但 ...

  4. Ubuntu配置Android编译环境

    1.Ubuntu安装 VMware安装ubuntu之后,安装Vmware tools: 1.安装完ubuntu后,VMware Workstation菜单:虚拟机-->安装 Vmware Too ...

  5. Windows XP环境下 搭建Android NDK环境

    搭建Android NDK环境 Windows XP环境下 1 一些下载 ① NDK r7:http://developer.android.com/sdk/ndk/index.html ② cygw ...

  6. 【转】在Eclipse下搭建Android开发环境教程

    本文将全程演示Android开发环境的搭建过程,无需配置环境变量.所有软件都是写该文章时最新版本,希望大家喜欢.   一 相关下载 三 Eclipse配置 (1)Java JDK下载 1 安装andr ...

  7. ubuntu配置android开发环境和编译源码遇到的一些问题

    ---------------------------------------------环境变量设置--------------------------------------------- 1.设 ...

  8. Android开发:修改eclipse里的Android虚拟机路径

    一.发现问题: 今天打开电脑发现C盘缩了不少,这才意识到:eclipse里配置的安卓虚拟机默认放在了C盘里. 当然,在不同的电脑上可能路径有所不同,我的默认路径是:C:\Users\lenovo\.a ...

  9. Ubuntu Linux下如何配置Android开发环境

    下载和安装Win7系统Android开发环境中讲了怎样在Win7系统中安装Android开发环境,那么怎样在Linux系统中配置Android开发环境呢?本篇文章就将演示如何使用Eclipse.And ...

随机推荐

  1. JavaScript开源跨平台框架NativeScript

    NativeScript是一款使用JavaScript语言来构建跨平台原生移动应用的开源框架,支持iOS.Android和Windows Phone.且NativeScript的使用没有过多繁杂的要求 ...

  2. share a story on OSPF & BGP

    IP掌门把两个得意门生——BGP和OSPF叫到跟前,询问他们的修炼心得,以选择弟子传授大内心法——MPLS VPN.OSPF说:“小徒苦心研读路由原理,技术资料上万页,网络在我的围护下无环路,触发更新 ...

  3. Ubuntu 安装软件方法

    Ubuntu软件安装有几种方式,常用的是deb包的安装方式,deb是debian系列的Linux包管理方式,Ubuntu软件安装属于debian的派生,也默认支持这种软件安装方式,当下载到一个deb格 ...

  4. Self20171218_Assert断言使用

     一.Assert用法: assertion(断言)在软件开发中是一种常用的调试方式,很多开发语言中都支持这种机制.在实现中,assertion就是在程序中的一条语句,它对一个boolean表达式进行 ...

  5. python一天一题(1)

    #有一个文件,文件名为output_1981.10.21.txt . # 下面使用Python: 读取文件名中的日期时间信息,并找出这一天是周几. # 将文件改名为output_YYYY-MM-DD- ...

  6. SSH框架环境搭建问题:java.lang.IllegalArgumentException: 'sessionFactory' or 'hibernateTemplate' is required

    SSH框架启动tomcate时出错 严重: Exception sending context initialized event to listener instance of class org. ...

  7. CI框架 -- 驱动器

    驱动器目录及文件结构 下面是驱动器目录和文件结构布局的简单例子: /application/libraries/Driver_name Driver_name.php //驱动器名称 drivers ...

  8. Linux定时任务工具crontab详解及系统时间同步

    Linux配置自动时间同步 linux下时间同步的两种方法分享 tail -f /var/log/cron linux下定时执行任务的方法  在LINUX中你应该先输入crontab -e,然后就会有 ...

  9. (实用)Linux下安装JDK和Eclipse

    安装Eclipse时前需要确保系统中已经具备Java运行环境,本文以干净系统初次安装Eclipse为例,同时安装JDK和Eclipse. 1.下载JDK压缩包: http://www.oracle.c ...

  10. Oracle错误IMP-00010: 不是有效的导出文件, 头部验证失败 分类: Oracle 2015-07-09 13:56 20人阅读 评论(0) 收藏

    Oracle 11g的dmp备份文件导入到Oracle 10g,出现错误信息: Import: Release 10.2.0.1.0 - Production on 星期四 7月 9 13:47:04 ...