- 浏览: 308821 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
a455642158:
xiajy 写道他妈的都该名字了,更可恶的金山手机助手是:sj ...
解决ADB server didn't ACK问题 -
wwt455653509:
关闭tadb.exe,重启eclipse搞定
解决ADB server didn't ACK问题 -
Frederic:
感谢,真是帮了大忙!腾讯
解决ADB server didn't ACK问题 -
xiajy:
他妈的都该名字了,更可恶的金山手机助手是:sjk_daemon ...
解决ADB server didn't ACK问题 -
xiaofeilv321:
赞同
解决ADB server didn't ACK问题
PS:I found a very useful article about cygwin with android ndk, so I copy it here to help others may have the same problems, the original address is http://pielot.org/2010/12/09/using-cygwin-with-the-android-ndk-on-windows/
This tutorial illustrates how to setup and use the Android NDK under Windows. It will use cygwin for compiling the native code. It has been tested on Windows XP and Windows 7.
This guide assumes that you have Eclipse and the Android SDK version 3 (1.5) up and running.
There are three important paths:
Eclipse Workspace D:\Dev\workspace-android
NDK D:\Dev\SDKs\android-ndk-r4b
Cygwin C:\Cygwin
I am using these paths as they appear on my computer. Please adapt them to use system if necessary. Note that the paths MUST NOT CONTAIN SPACES.
The code for this tutorial is available here
Download NDK
Go to http://developer.android.com/sdk/ndk/index.html and download the Android NDK for Windows. At the time of writing, android android-ndk-r4b was the latest version. Copy the folder into D:\dev\SDKs\
Install Cygwin
Download setup.exe from http://cygwin.com/. Currently http://cygwin.com/setup.exe as direct link. Execute setup.exe and select a server to download the Cygwin files from. Then a huge list appears where you can select the components to download.
Add “Devel/make” and “Shells/bash”. Search for “make” and “shell” to find them. Press next to download. I installed all files to C:\cygwin.
Create Android Project
Create a new standard Android project. I called it HelloNDK and used the following code.
Running this code should fail, as there is no native library yet.
Create Java Native Interface
Make sure your PATH contains your Java SDKs /bin directory. Open a terminal (cmd.exe) and enter javah. Receiving something like this means everything is alright.
Now, in the terminal, go to the root of your project in Eclipse’s workspace D:\Dev\workspace-android\HelloNDK. Enter
When no error occurs, the compilation was successful. Now you should find a new folder jni in your project, containing the file org_pielot_hellondk_HelloNDK.h
For my convenience, I usually create a .bat file including the above javah command and put it into the project folder.
Implement the Native Interface
Now we have to provide an implementation of the generated header file. Create org_pielot_hellondk_HelloNDK.c in the same folder as org_pielot_hellondk_HelloNDK.h and fill it with:
Inform the Compiler what Files to Compile
Next, we have to inform the NDK compiler what files should be compiled. In the /jni folder we therefore create “Android.mk” including
Compiling the Native Code
In the HelloNDK project folder create a batch file named “make.bat”. Fill it with:
ATTENTION, this file will NOT WORK WHEN EXECUTED FROM WITHIN ECLIPSE. Thus, always find it with the Windows Explorer and execute it by double-clicking.
If successful it should look like
In the HelloNDK project directory you now should find libs/armeabi/libhellondk.so created
Loading and Testing library
If you now run the HelloNDK Activity you should see no exceptions. In LogCat, something like
should appear. Voila! You have done it!
One last note: if you are just working on the C code, Eclipse will not realize that the native lib has been updated. To make sure that the latest version of the lib will be used, mark the HelloNDK project in Eclipse’s project explorer and hit F5.
This tutorial illustrates how to setup and use the Android NDK under Windows. It will use cygwin for compiling the native code. It has been tested on Windows XP and Windows 7.
This guide assumes that you have Eclipse and the Android SDK version 3 (1.5) up and running.
There are three important paths:
Eclipse Workspace D:\Dev\workspace-android
NDK D:\Dev\SDKs\android-ndk-r4b
Cygwin C:\Cygwin
I am using these paths as they appear on my computer. Please adapt them to use system if necessary. Note that the paths MUST NOT CONTAIN SPACES.
The code for this tutorial is available here
Download NDK
Go to http://developer.android.com/sdk/ndk/index.html and download the Android NDK for Windows. At the time of writing, android android-ndk-r4b was the latest version. Copy the folder into D:\dev\SDKs\
Install Cygwin
Download setup.exe from http://cygwin.com/. Currently http://cygwin.com/setup.exe as direct link. Execute setup.exe and select a server to download the Cygwin files from. Then a huge list appears where you can select the components to download.
Add “Devel/make” and “Shells/bash”. Search for “make” and “shell” to find them. Press next to download. I installed all files to C:\cygwin.
Create Android Project
Create a new standard Android project. I called it HelloNDK and used the following code.
package org.pielot.hellondk; import android.app.Activity; import android.os.Bundle; import android.util.Log; public class HelloNDK extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); System.loadLibrary("hellondk"); int result = sayHello(); Log.i("HelloNDK", "" + result); } private native int sayHello(); }
Running this code should fail, as there is no native library yet.
Create Java Native Interface
Make sure your PATH contains your Java SDKs /bin directory. Open a terminal (cmd.exe) and enter javah. Receiving something like this means everything is alright.
Now, in the terminal, go to the root of your project in Eclipse’s workspace D:\Dev\workspace-android\HelloNDK. Enter
javah.exe -classpath bin -d jni org.pielot.hellondk.HelloNDK
When no error occurs, the compilation was successful. Now you should find a new folder jni in your project, containing the file org_pielot_hellondk_HelloNDK.h
/* DO NOT EDIT THIS FILE - it is machine generated */ #include /* Header for class org_pielot_hellondk_HelloNDK */ #ifndef _Included_org_pielot_hellondk_HelloNDK #define _Included_org_pielot_hellondk_HelloNDK #ifdef __cplusplus extern "C" { #endif /* * Class: org_pielot_hellondk_HelloNDK * Method: sayHello * Signature: ()I */ JNIEXPORT jint JNICALL Java_org_pielot_hellondk_HelloNDK_sayHello (JNIEnv *, jobject); #ifdef __cplusplus } #endif #endif
For my convenience, I usually create a .bat file including the above javah command and put it into the project folder.
Implement the Native Interface
Now we have to provide an implementation of the generated header file. Create org_pielot_hellondk_HelloNDK.c in the same folder as org_pielot_hellondk_HelloNDK.h and fill it with:
#include "org_pielot_hellondk_HelloNDK.h" JNIEXPORT int JNICALL Java_org_pielot_hellondk_HelloNDK_sayHello (JNIEnv * env, jobject obj) { return 42; }
Inform the Compiler what Files to Compile
Next, we have to inform the NDK compiler what files should be compiled. In the /jni folder we therefore create “Android.mk” including
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := hellondk LOCAL_SRC_FILES := org_pielot_hellondk_HelloNDK.c include $(BUILD_SHARED_LIBRARY)
Compiling the Native Code
In the HelloNDK project folder create a batch file named “make.bat”. Fill it with:
@echo on @set BASHPATH="C:\cygwin\bin\bash" @set PROJECTDIR="/cygdrive/d/dev/workspace-android/hellondk" @set NDKDIR="/cygdrive/d/dev/SDKs/android-ndk-r4b/ndk-build" %BASHPATH% --login -c "cd %PROJECTDIR% && %NDKDIR% @pause:
ATTENTION, this file will NOT WORK WHEN EXECUTED FROM WITHIN ECLIPSE. Thus, always find it with the Windows Explorer and execute it by double-clicking.
If successful it should look like
In the HelloNDK project directory you now should find libs/armeabi/libhellondk.so created
Loading and Testing library
If you now run the HelloNDK Activity you should see no exceptions. In LogCat, something like
12-05 13:42:45.311: INFO/HelloNDK(24329): 42
should appear. Voila! You have done it!
One last note: if you are just working on the C code, Eclipse will not realize that the native lib has been updated. To make sure that the latest version of the lib will be used, mark the HelloNDK project in Eclipse’s project explorer and hit F5.
发表评论
-
使用fatjar导出有第三方库引用的jar
2013-11-26 16:24 1368把android项目导出为jar时,老是不能把第三方库一起导出 ... -
(转)关于百度地图和高德地图,关于地图坐标系
2013-11-21 11:23 8778原文作者: 深白Andy 原 ... -
android操作png
2013-10-16 11:31 1410PNGJ是纯Java库的高效编码解码/ PNG图像的库,开源项 ... -
通过SharedPreference实现共享数据
2013-04-22 17:07 2318如果程序B想要访问程序A的sharedPreference可以 ... -
android 安装app私有存储目录下的apk
2013-04-08 18:05 3234一般安装app就是 Intent i = new Intent ... -
android在线播放音频视频
2012-12-05 17:43 1891在项目中要用到终端现场录制视频音频,用户在web页面看,所以找 ... -
Android video streaming and encoder
2012-11-26 15:38 1607一个开源的android流媒体项目https://code.g ... -
锁定屏幕
2012-10-24 21:52 1193if (!mDPM.isAdminActive(mDevice ... -
android 企业级开发框架
2012-10-24 17:38 1274http://code.google.com/p/openmo ... -
afinal 开发框架
2012-10-20 18:03 1227afinal 是一个android的 orm 和 ioc 框架 ... -
在后台保持屏幕唤醒状态
2012-10-16 21:05 988在网上找了很久,都是在前台起作用的,只有自己实现了,还有些小问 ... -
基于经纬度计算方向,距离等
2012-10-11 12:57 1511The code encapsulating a locati ... -
NFC Android 应用开发指南
2012-09-30 14:44 1373文档里说的很详细很有用,能看完,对NFC在android上的开 ... -
(转)百度地图API经纬度转换接口
2012-09-28 20:55 31672先列参考文 百度提供的各种地图API http://dev.b ... -
(转)google地图纠偏
2012-09-28 12:13 2018由于受到国家一些法律 ... -
位置服务的封装
2012-09-24 21:33 925/** * Retrieve accurate locat ... -
结合重力感应器来计算手机移动的方位
2012-09-24 21:24 1171public void onSensorChanged( Se ... -
根据Latitude/Longitude 计算方位,距离等
2012-09-24 21:09 3942里面有详细的说明http://www.movable-type ... -
通过google api获得位置的方向
2012-09-23 15:10 954private String[] getDirectio ... -
模拟位置信息
2012-09-23 12:40 1156计算两点间距离 方法一 double dist = 0.0; ...
相关推荐
windows下eclipse集成cygwin编译android_NDK.doc
Cygwin+Android_NDK的安装,及环境变量配置,及运行实例
android NDK 安装必备 Cygwin
android NDk cygwin make安装包
Android NDK 交叉编译工具 Android NDK 交叉编译工具
android ndk 开发环境配置,不需要cygwin,可直接生成.h文件,直接编译库
Android NDK r5 windows系统上安装与使用
android NDK CDT cygwin开发环境搭建与配置
NDK提供了一系列的工具,帮助开发者快速开发C(或C++)的动态库,并能自动将so和java应用一起打包成apk,并集成了交叉编译器,并提供了相应的mk文件隔离CPU、平台、ABI等差异,开发人员只需要简单修改mk文件
本文档主要总结了cygwin结合android NDK的应用
Eclipse集成Android NDK说明 1 2 为什么要用NDK? 2 3 为什么要集成? 2 4 怎样操作? 2 4.1 预备条件 2 4.1.1 Cygwin 2 4.1.2 Eclipse 2 4.1.3 Eclipse CDT 3 4.1.4 Android SDK 3 4.1.5 Android NDK 3 ...
cygwin ,仅含android ndk所需要的功能,autoconf2.1、automake1.10、binutils、gcc-core、gcc- g++、gcc4-core、gcc4-g++、gdb、pcre、pcre-devel、gawk、make共12个包。 安装了直接可以用
cygwin安装程序+ndk环境搭建以及opengl在ndk环境中的使用说明
Cygwin v1.7.9版离线安装包支持最新版Android NDK r7,压缩包有cygwin-setup.exe安装工具及离线安装资源,包含NDK需要的包:autoconf2.1、automake1.10、binutils、gcc-core、gcc-g++、gcc4-core、gcc4-g++、gdb、...
因很多cygwin离线包丢失make命令,故 增加gunmake3.81, 支持android-ndk-r4以上版本共5个压缩文件
window 下eclipse、cygwin、 cdt ndk的详细配置文档。
Cygwin v1.7.9版离线安装包支持最新版Android NDK r7,压缩包有cygwin-setup.exe安装工具及离线安装资源,包含NDK需要的包:autoconf2.1、automake1.10、binutils、gcc-core、gcc-g++、gcc4-core、gcc4-g++、gdb、...
64位windows下ndk,方便直接使用。cygwin+ndk+FFmpeg配合使用,编译Android 动态库进行视频编辑。
1.1.5 在Windows平台上下载并安装AndroidNDK 1.1.6 在Windows平台上下载并安装Eclipse 1.2 AppleMacOSX 1.2.1 在Mac平台上安装Xcode 1.2.2 验证Mac平台的Java开发包 1.2.3 验证Mac平台上的ApacheANT 1.2.4 验证GNU...