当前位置: 首页 > news >正文

在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 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:

 
from:http://blog.csdn.net/zengyangtech/article/details/7019350

相关文章:

  • 把SOA看清楚
  • yafeilinux.com的开源项目非常好的东西
  • 从问题看本质:socket到底是什么?
  • LINQ之路 4:LINQ方法语法
  • matlab练习程序(异或分类)
  • REST构架风格介绍之二:CRUD
  • Silverlight for Windows Phone 7开发系列(4):动画开发
  • BizTalk 2013 Beta 新特性介绍
  • 剖析Elasticsearch集群系列之一:Elasticsearch的存储模型和读写操作
  • 如何实现在firefox下显示手形光标
  • QTP的那些事--systemutil对象使用
  • 使用泛型解决需要动态返回类型的问题
  • 解决接收不到组播包的问题
  • Java @Override报错
  • 简单的汉化ECLIPSE的办法 [转]
  • 9月CHINA-PUB-OPENDAY技术沙龙——IPHONE
  • 【译】React性能工程(下) -- 深入研究React性能调试
  • gops —— Go 程序诊断分析工具
  • JavaWeb(学习笔记二)
  • Lsb图片隐写
  • Next.js之基础概念(二)
  • nodejs调试方法
  • Python 使用 Tornado 框架实现 WebHook 自动部署 Git 项目
  • vagrant 添加本地 box 安装 laravel homestead
  • 从tcpdump抓包看TCP/IP协议
  • 基于Android乐音识别(2)
  • 看图轻松理解数据结构与算法系列(基于数组的栈)
  • 利用DataURL技术在网页上显示图片
  • 七牛云假注销小指南
  • 收藏好这篇,别再只说“数据劫持”了
  • 首页查询功能的一次实现过程
  • 双管齐下,VMware的容器新战略
  • 网络应用优化——时延与带宽
  • 问题之ssh中Host key verification failed的解决
  • 小程序开发中的那些坑
  • 学习使用ExpressJS 4.0中的新Router
  • 自动记录MySQL慢查询快照脚本
  • 策略 : 一文教你成为人工智能(AI)领域专家
  • ​ ​Redis(五)主从复制:主从模式介绍、配置、拓扑(一主一从结构、一主多从结构、树形主从结构)、原理(复制过程、​​​​​​​数据同步psync)、总结
  • # 执行时间 统计mysql_一文说尽 MySQL 优化原理
  • #### go map 底层结构 ####
  • (紀錄)[ASP.NET MVC][jQuery]-2 純手工打造屬於自己的 jQuery GridView (含完整程式碼下載)...
  • (每日持续更新)jdk api之StringBufferInputStream基础、应用、实战
  • (转) SpringBoot:使用spring-boot-devtools进行热部署以及不生效的问题解决
  • (转)jQuery 基础
  • (转)可以带来幸福的一本书
  • (转载)Linux网络编程入门
  • .NET Core实战项目之CMS 第十二章 开发篇-Dapper封装CURD及仓储代码生成器实现
  • .NET Framework Client Profile - a Subset of the .NET Framework Redistribution
  • .Net Web项目创建比较不错的参考文章
  • .net 反编译_.net反编译的相关问题
  • .NET 设计一套高性能的弱事件机制
  • .NET6 命令行启动及发布单个Exe文件
  • .net的socket示例
  • .NET委托:一个关于C#的睡前故事