Win7+Eclipse+Android+NDK+Cocos2dx

Feature:

A. do not need cygwin.

B. we could set breakpoint and debug the native C++ part code in Eclipse.

 

System and Software Version:

Laptop: ASUS

OS:win7 64bit ultimate

JDK:jdk-7u15-windows-x64

JRE:jre-7u17-windows-x64

Eclipse:eclipse-SDK-4.2.2-win32-x86_64

ADT:installer_r21.1-windows

NDK:android-ndk-r8e-windows-x86_64

CDT:http://download.eclipse.org/tools/cdt/releases/indigo

Cocos2d-x:cocos2d-2.1rc0-x-2.1.2

 

Helpful Websites and Blogs:

AndroidDevelopers      Android Tools ProjectSite      Felix.mao'sblog      VeryDemo   ttun's blog

 

Following is my installing process:

1. Install JDK and JRE, set the system environment variables (so that we could run eclipse).

Here is my settings:

JAVA_HOME: D:\Java\jdk\bin

CLASS_PATH: D:\Java\jdk\bin

Path: D:\Java\jdk\bin

2. Install Eclipse.

3. Use the Eclipse Help install relative plugins:C\C++Develpment Tools(CDT),ADT.

4. Then I found my ADT not work, so Iinstalled ADT installer_r21.1-windows, then I can use the ADT in Eclipse and installed the  Android SDK.

5. Install NDK. After unzipping and installing the NDK. We need set path param in Eclipse as follows: goto:Window>Preferences>Android>NDK: set the NDK Location as your ndk root directory like D:\android-ndk-r8e.

6. Import the sample android project HelloCPP of cocos2d-2.1rc0-x-2.1.2 into Eclipse and build, error comes, it says org.cocos2dx.lib not found.

7. I searched on the Internet and import the cocos2d-2.1rc0-x-2.1.2\cocos2dx\platform\android\javawhich is the cocos2dx library project ,then import the libcocos2dx.jar into the HelloCPP project and the probem above is solved.

8. Set the NDK running parameters as here says.

9. Then I start build the project with ndk,and error comes again, it says libcocos2dx not found.

10. To fix the error above I did as here says, created a new program builder for the project and set the argumentsas:NDK_MODULE_PATH:=D:\work\cocos2d-2.1rc0-x-2.1.2;D:\work\cocos2d-2.1rc0-x-2.1.2\cocos2dx/platform/third_party/android/prebuilt and there must not exist space in the path.

11. Then I build the project, wow, itstarted to build, I was so happy, then it built ok.

12. Then I started to run the project, but eclipse said the project couldn't be run as there still exist error in thepoject,I found there is an error mark in the Android.mk file, that line is$(call import-module,cocos2dx), but I couldn't know what is the error.

13. I searched a lot again but found nothing until I see this, and I change the project as it says, everything worksok, pretty thanks, thoug I still don't know why the above error will exist, but now disappears.

14. I build the project , ndk build ok.Then I created a Android Virtul Machine to run it but when the logcat says the apk is install and opened but it is just black.

15. I run the project on my android phone,ok, I see the HelloWorld.

16.I set a break point in the native code HelloWorldScene.cpp at line 83 which is the callback function of the close button,and when I touch the button the program stopped at the breakpoint. Yes,it works, the native C++ could be debugged.

發佈了32 篇原創文章 · 獲贊 10 · 訪問量 11萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章