How to Build a Android Project with Eclipse
Before you install cocos2d-x under Ubuntu, make sure you install it correctly.
English Link: https://github.com/chukong/cocos-docs/blob/master/manual/framework/native/v3/getting-started/ How-to-run-cpp-tests-on-android/en.md
Brief description:
1. Download Cocos2d-x
2. Download JDK, SDK and NDK
3, confirm the environment: Python more than 2.7, command: python-version
4, install ant tools, use homebrew installation, under Ubuntu is linuxbrew, installation reference http://brew.sh/linuxbrew/
To install Linuxbrew, install the command:
Ruby-e "$ (wget-o-https://raw.github.com/Homebrew/linuxbrew/go/install)"
Or use git to install: Git clone https://github.com/Homebrew/linuxbrew.git ~/.linuxbrew
Ruby Installation:
sudo apt-get install build-essential curl git m4 ruby texinfo libbz2-dev Libcurl4-openssl-dev Libexpat-dev Libncurses-dev Zlib1g-dev
To configure ~/.BASHRC, use Gedit to add the following statement to the end:
Export path= "$HOME/.linuxbrew/bin: $PATH"
Export ld_library_path= "$HOME/.linuxbrew/lib: $LD _library_path"
Update. BASHRC, command: Source ~/.BASHRC
Installing Ant,brew install ant using the Brew Install command
5. Configure your Android development environment with setup.py
Go to the Cocos2d-x directory and run Python setup.py
When the script asks you to configure the Ant_root, you can simply press ENTER to let the script do the rest of the work.
If all environment variables are configured correctly, make them effective. The class *nix system commands are as follows:
SOURCE ~/.bash_profile
Under Ubuntu I use source ~/.BASHRC
6. Build Cocos2d-x samples with android-build.py
Change the current directory to the directory where android-build.py is located:
CD Build
And then
Python android-build.py-p Ten Cpp-tests
Tip Error "update Cocos Lib-project [/home/chain78/cocos2d-x/build/. /cocos/platform/android/java] fails! "
FIX: Enter Android list targets view Android version, show as android-20
The Modify command is:
Python android-build.py-p cpp-tests
Try entering only Python android-build.py and you'll get help options.
7. How do I deploy a project to an Android phone via the command line?
1) Check whether your phone USB debugging is available, if not available, open "settings-about Device", click "Version number" five times
Developer options will appear
Connect your device via a data cable
2) Enter the bin directory under the Testcpp Android project:
CD ~/cocos2d-x/tests/cpp-tests/proj.android/bin
3) use ADB to install APK on Android phone:
ADB install cpptests-debug.apk
If you are prompted that ADB is not a command, then you can run the following command at the terminal or add the following code to the file in ~/BASHRC.
Export path= $PATH: $ANDROID _sdk_root/tools: $ANDROID _sdk_root/platform-tools
Cheer Up! The test program on the phone ran successfully! Small achievements, the long march out of the first step!
Community Exchange: Http://discuss.cocos2d-x.org/category/5-category
Links: https://github.com/chain78/cocos-docs/blob/master/manual/framework/native/v3/getting-started/ How-to-build-android-project-with-eclipse/en.md
Build an Android project with Eclipse
First, the work flow
When we build an Android project, the workflow is this:
1. Go to proj.android directory run: Python build_native.py
If you are trying to build cpp-tests, you must go to the build directory and run Python android-build.py-p cpp-tests
2. Eclipse opens the existing Android project
3, Import LIBCOCOS2DX project. (Note: Do not import the LIBCOCOS2DX project into the Cocos2d-x directory unless you are building
Cpp-tests Project. If you use the Cocos command to create a project, make sure that LIBCOCOS2DX is imported in your own project directory. )
4. Compile and run the Android project.
The following two examples demonstrate this workflow:
1. Build Cpp-tests
1) Build cpp-tests using Python scripts
CD Cocos2d-x/build
Python android-build.py-p cpp-tests
If you run successfully, check if libcpp_tests.so is located in [Cocos2d-x root]tests/cpp-tests/proj.android/libs/armeabi/libcpp_tests.so
2) Open Proj.android project with Eclipse
Run Eclipse
Right-click your mouse in the blank area of the Package Explorer and select InPort ...
Select existing Android Code into Workspace, click Next
Select Browse ..., select proj.android, click OK
3) Import LIBCOCOS2DX Project
In addition to the imported paths, the process is similar to the
L IBCOCOS2DX Path is: [Your cocos2d-x Root]cocos/2d/platform/android/java
4) compiling and running Android projects
Connect your phone to see if the USB Remote debugging option is available.
Make sure your computer can identify your phone, or install a mobile phone driver accordingly.
Right click on the Cpp-tests project, click Run as ...--Android application
2. Build an empty project with Cocos command
1) Cocos Command creation
Cocos Run-s ~/mycompany/mygame-p Android
See https://github.com/chukong/cocos-docs/blob/master/manual/framework/native/v3/getting-started/for details. How-to-start-a-new-game/en.md
2) Open Proj.android project with Eclipse
3) Import LIBCOCOS2DX Project
Remember to import libcocos2dx into the Mygame directory, not the engine root directory.
4) compiling and running Android projects
Problem exclusion
If you import an Android project that gets an error in eclipse. Do not panic, import the LIBCOCOS2DX project will be resolved.
If you have already imported all the items and the error persists, you may need to manually compile the LIBCOCOS2DX project and see if the Libcocos2dx.jar file is generated in the bin directory.
If you have installed your item on the phone, but crashes on startup. You should check the Libs/armeabi folder to make sure that the libxxx.so file is generated.
This article is from the "chain78" blog, make sure to keep this source http://5853784.blog.51cto.com/5843784/1552682
How to create an Android project from eclipse