在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. 【AndroidManifest.xml详解】Manifest属性之sharedUserId、sharedUserLabel

    http://blog.csdn.net/wirelessqa/article/details/8581652 android:sharedUserId 当APK安装的时候,userid这个标志就会产 ...

  2. 实验一 ASP.NET应用环境配置 总结

    通过本次实验我学会了在Windows XP系统中安装IIS服务器,虽然我的电脑是Windows7系统,但是通过虚拟机软件,配置了一台Windows XP系统的虚拟机,在虚拟机内进行各项配置操作.这次实 ...

  3. Linux命令_用户身份切换

    命令 su 格式为:su [ - ] username,后面可以跟 - ,也可以不跟. 普通用户的su命令不加username时,就相当于切换到root用户,反之亦然.当su 命令加上 - 后,会初始 ...

  4. Luhn算法检验和验证

    一.Luhn公式介绍 Luhn公式是一种广泛使用的系统,用于对标识号进行验证.它根据原始标识号,把每隔一个数字的值扩大一倍.然后把各个单独数字的值加在一起(如果扩大一倍后的值为2个数字,就把这两个数字 ...

  5. e867. 获取和设置外观

    To change the look and feel, you need to know the class name of the new look and feel. This example ...

  6. Unity GUI(uGUI)使用心得与性能总结

    Unity GUI(uGUI)使用心得与性能总结 作者 kingshijie 关注 2015.09.26 15:35 字数 3686 阅读 28031评论 10喜欢 49 背景和目的 小哈接触Unit ...

  7. u3d 发布的程序 窗口位置的改变

    using System; using System.Runtime.InteropServices; using UnityEngine; public class WindowMOD : Mono ...

  8. yum更换国内源 yum下载rpm包 源码包安装

    7.6 yum更换国内源 7.7 yum下载rpm包 7.8/7.9 源码包安装 yum更换国内源 cd  /etc/yum.repo.d/ 删除源 rm -f   dvd.repo rm -f  C ...

  9. php 区分0和空

    能够区分出来的有2,4,6 方法 public function test(){ $test=; if($test==''){ echo '<br />在php中1,0即为空'; //被输 ...

  10. WebGL 绘制和变换

    1.使用缓冲区对象向顶点着色器传入多个顶点的数据,需要遵循以下五个步骤: 1.1 创建缓冲区对象(gl.createBuffer()). 1.2 绑定缓冲区对象(gl.bindBuffer()). 1 ...