Cocos2d-x environment setup for eclipse
Install Cygwin and add the NDK_ROOT environment variable to Cygwin's Home/(user)/. base_profile.
NDK_ROOT =/cygdrive/d/Android/android-ndk-r8e.
Export NDK_ROOT
Open the cocos2d-x unzip the root directory and find the file create-android-project.bat open.
See these lines
: Modify it to work under your environment // modify this directory to point to your Cygwin bin directory
Set _ CYGBIN = e: \ cygwin \ bin
If not exist "% _ CYGBIN %" echo Couldn't find Cygwin at "% _ CYGBIN %" & pause & exit 4
: Modify it to work under your environment // modify this directory to point to the tools directory of your Android sdk
Set _ ANDROIDTOOLS = e: \ android-sdk \ tools
If not exist "% _ ANDROIDTOOLS %" echo Couldn't find android sdk tools at "% _ ANDROIDTOOLS %" & pause & exit 5
: Modify it to work under your environment // modify this directory to point to your NDK root directory
Set _ NDKROOT = e: \ android \ android-ndk-r8
If not exist "% _ NDKROOT %" echo Couldn't find ndk at "% _ NDKROOT %" & pause & exit 6
Double-click to run the create-android-project.bat file first prompts you to enter the package name, then the project name, the last sdk version
Created successfully, you will see your new project under the root directory of the cocos2d-x
The Classes, proj. android, and Resources directories are in the C ++ source code directory, proj. android is the Android project, and Resources is the Resource Directory.
Add a sentence to proj. android/jni/Application. mk of the corresponding project.
APP_CFLAGS + =-Wno-error = format-security
Compile the project, open Cygwin, enter the newly created android root directory, and run the build_native.sh file (enter./build_native.sh). This is a compilation process until the compilation ends.
Import the Android project to Eclipse
Problem description:
After build_native.sh runs successfully, this problem occurs after the project is imported to eclipse. the following files cannot be found:
Import org. cocos2dx. lib. Cocos2dxActivity;
Solution:
1. just copy the cocos2dx/platform/android/java/src folder under the root directory of the cocos2d-x engine to the src package of the project.
2. You can also import the cocos2dx/platform/android/java project to generate a jar file and add it to the libs folder of the project.
Both methods will copy the dependency to the apk when it is generated.