- 浏览: 315933 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
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 1435把android项目导出为jar时,老是不能把第三方库一起导出 ... -
(转)关于百度地图和高德地图,关于地图坐标系
2013-11-21 11:23 8877原文作者: 深白Andy 原 ... -
android操作png
2013-10-16 11:31 1470PNGJ是纯Java库的高效编码解码/ PNG图像的库,开源项 ... -
通过SharedPreference实现共享数据
2013-04-22 17:07 2431如果程序B想要访问程序A的sharedPreference可以 ... -
android 安装app私有存储目录下的apk
2013-04-08 18:05 3359一般安装app就是 Intent i = new Intent ... -
android在线播放音频视频
2012-12-05 17:43 1983在项目中要用到终端现场录制视频音频,用户在web页面看,所以找 ... -
Android video streaming and encoder
2012-11-26 15:38 1701一个开源的android流媒体项目https://code.g ... -
锁定屏幕
2012-10-24 21:52 1307if (!mDPM.isAdminActive(mDevice ... -
android 企业级开发框架
2012-10-24 17:38 1390http://code.google.com/p/openmo ... -
afinal 开发框架
2012-10-20 18:03 1304afinal 是一个android的 orm 和 ioc 框架 ... -
在后台保持屏幕唤醒状态
2012-10-16 21:05 1059在网上找了很久,都是在前台起作用的,只有自己实现了,还有些小问 ... -
基于经纬度计算方向,距离等
2012-10-11 12:57 1619The code encapsulating a locati ... -
NFC Android 应用开发指南
2012-09-30 14:44 1480文档里说的很详细很有用,能看完,对NFC在android上的开 ... -
(转)百度地图API经纬度转换接口
2012-09-28 20:55 31766先列参考文 百度提供的各种地图API http://dev.b ... -
(转)google地图纠偏
2012-09-28 12:13 2112由于受到国家一些法律 ... -
位置服务的封装
2012-09-24 21:33 1018/** * Retrieve accurate locat ... -
结合重力感应器来计算手机移动的方位
2012-09-24 21:24 1238public void onSensorChanged( Se ... -
根据Latitude/Longitude 计算方位,距离等
2012-09-24 21:09 4051里面有详细的说明http://www.movable-type ... -
通过google api获得位置的方向
2012-09-23 15:10 1061private String[] getDirectio ... -
模拟位置信息
2012-09-23 12:40 1215计算两点间距离 方法一 double dist = 0.0; ...
相关推荐
### Windows 下 Eclipse 集成 Cygwin 编译 Android NDK 在 Windows 环境下使用 Eclipse 开发 Android 应用时,如果需要利用 C 或 C++ 的功能,通常会涉及到 Android NDK 的使用。为了更好地整合开发流程,可以将 ...
Cygwin通过模拟Linux API来实现这一功能,使得许多依赖于Unix/Linux环境的工具能够在Windows上运行,包括Android NDK的构建工具链。 在安装Cygwin的过程中,我们需要确保选择正确的包,以支持NDK的构建需求。这些包...
3. **Cygwin在Android NDK中的作用**:通过Cygwin,开发者可以在Windows环境下配置和使用NDK,实现对Android的交叉编译,包括设置编译器、链接器和其他构建工具。 **三、Android NDK的配置与使用** 1. **下载和...
Android NDK环境配置是Android应用开发中的一个重要环节,它允许开发者使用C或C++编写高性能的原生代码,这些代码可以被编译成动态库并与Java应用一同打包成APK。NDK集成了交叉编译器,使得开发者能够针对不同的CPU...
本文将深入探讨Android NDK R20B版本,特别是其在64位Windows环境下的应用,以及如何与cygwin、FFmpeg等工具协同工作,实现视频编辑功能的动态库编译。 Android NDK是Google提供的一个开源工具集,它允许开发者在不...
在Windows环境下进行Android原生代码开发,通常会涉及到Eclipse、Cygwin、CDT和NDK这四个组件。下面将详细介绍它们的功能以及如何配置。 首先,Eclipse是一款广泛使用的集成开发环境(IDE),尤其在Java开发领域。...
### 非常强大的Eclipse中Android NDK开发环境的配置说明 #### 一、概述 本文档将详细介绍如何在Eclipse中配置Android NDK开发环境,并实现C/C++代码的自动编译以及通过Eclipse使用Ant生成JNI所需的头文件。配置流程...
本文将详细介绍如何在Windows 64位操作系统环境下配置Android NDK开发环境,并实现无需借助Cygwin即可快速生成`.h`文件及直接编译库的过程。 #### 二、所需工具与环境 在开始之前,请确保您的开发环境中已安装以下...
android NDk cygwin make安装包
通过上述步骤,您不仅了解了Android NDK的基本概念及其重要性,还掌握了如何在Windows平台上搭建和配置基于Cygwin的NDK开发环境。这为后续利用C/C++进行Android原生应用开发奠定了坚实的基础。随着实践的深入,您将...
Windows下Android NDK环境配置 一、什么是NDK? NDK(Native Development Kit)是一款提供了一系列工具帮助开发者快速开发C(或C++)动态库,并能自动将.so和Java应用一起打包成apk的开发工具。这些工具对开发者的...
- **Cygwin**:一个在Windows环境下提供Linux命令行环境的软件,用于执行NDK所需的命令行工具。 - **Eclipse**:选择安装了ADT(Android Developer Tools)的版本,这是Eclipse专门为Android开发设计的插件。 - **...
- **操作系统**:官方推荐使用 Ubuntu 系统进行开发,但在 Windows 上也可以通过 Cygwin 实现对 NDK 的支持。 - **版本要求**:NDK 仅适用于 Android 1.5 及以上版本。 ##### 3.2 使用示例 开发者可以通过以下步骤...
总结,通过Cygwin和NDK,开发者可以在Windows环境下构建Android原生代码,利用OpenGL ES实现高效的图形处理。理解并熟练掌握这一流程,对于Android游戏开发或其他需要高性能计算的场景非常有益。在实际操作中,可能...