cocos2d-2.0-x-2.0.3 Cross compile to Android error resolution _android

Source: Internet
Author: User
I used the cocos2d-2.0-x-2.0.3, and I didn't make a day. Download the latest NDK8 update the SDK and again it was a success, I do not know is the version of the tool problem or which step out of the wrong, tidy up here .
First, the tools are all down and configured, and then the Cygwin in the. Bash_profile this file opens at the end with the NDK path
ndk_root=/cygdrive/c/android-ndk-r8d
Export Ndk_root

2. Find the Create-android-project.bat in cocos2dx this file is open and there are three places to change.
Set _cygbin=c:\cygwin\bin
Set _androidtools=e:\eclipse\and Sdk\tools
Set _ndkroot=c:\android-ndk-r8d
It's obviously not much to say.

3. After the modification, run this file and follow the prompts to create the Android project and replace the classes and resources in your previous written

4. Open Proj.android This file in the build_native.sh to edit the new version of the coco2.x and coco1.x before this file is not the same as 2.x this change for a long time is also not good for me to 1.x direct copy over to modify a bit
Copy Code code as follows:

# set Params
ndk_root_local=/cygdrive/c/android-ndk-r8d
cocos2dx_root_local=/cygdrive/e/cocos2d-2.0-x-2.0.3
Buildexternalsfromsource=
Usage () {
Cat << EOF
Usage: $ [options]
Build C + + native code using Android NDK
OPTIONS:
-S build externals from source
-H This Help
Eof
}
While getopts "S" OPTION; Todo
Case "$OPTION" in
S
Buildexternalsfromsource=1

H
Usage
Exit 0

Esac
Done
# try to get global variable
If [$NDK _root "AAA"!= "AAA"]; Then
echo "Use global definition of ndk_root: $NDK _root"
Ndk_root_local= $NDK _root
Fi
If [$COCOS 2dx_root "AAA"!= "AAA"]; Then
echo "Use global definition of cocos2dx_root: $COCOS 2dx_root"
Cocos2dx_root_local= $COCOS 2dx_root
Fi
helloworld_root= $COCOS 2dx_root_local/testcocos/proj.android
# Make sure assets is exist
If [-D $HELLOWORLD _root/assets]; Then
RM-RF $HELLOWORLD _root/assets
Fi
mkdir $HELLOWORLD _root/assets
# Copy Resources
For file in $COCOS 2dx_root_local/testcocos/resources/*
Todo
If [-D $file]; Then
CP-RF $file $HELLOWORLD _root/assets
Fi
If [f $file]; Then
CP $file $HELLOWORLD _root/assets
Fi
Done
if [[$buildexternalsfromsource]]; Then
echo "Building external dependencies from source"
$NDK _root_local/ndk-build-c $HELLOWORLD _root $* \
Ndk_module_path=${cocos2dx_root_local}:${cocos2dx_root_local}/cocos2dx/platform/third_party/android/source
Else
echo "Using prebuilt externals"
$NDK _root_local/ndk-build-c $HELLOWORLD _root $* \
Ndk_module_path=${cocos2dx_root_local}:${cocos2dx_root_local}/cocos2dx/platform/third_party/android/prebuilt
Fi

Inside the main is to configure a number of paths we should be good control of the green section I was this file configuration for a long time did not succeed in the back of how Not

5. Configure ANDROID.MK
The main configuration local_src_files This parameter if you do not add any class library, the rest of the parameters are not configured of course, produced a small game directly with the Cocos generated classes so this file does not have to change
Copy Code code as follows:

Local_src_files: = hellocpp/main.cpp \
.. /.. /classes/appdelegate.cpp \
.. /.. /classes/helloworldscene.cpp


6. Run Cygwin input CD $NDK carriage return
Then use the/cygdrive/to locate your build_native.sh file location.
And then enter./build_native.sh

You will compile your C + + code into the Android class file and copy the resource files or whatever.

7. Pour this item into eclipse
There may be a red fork in it, for example, you can't find a library file. This is to copy the Lib package in the COCOS2D-2.0-X-2.0.3\COCOS2DX\PLATFORM\ANDROID\JAVA\SRC directory into the project
There are other mistakes, but to click on the Item right button Androidtools->fix project and then replace the Java compiler with 1.6
There is a class generated in this sentence do not change
Copy Code code as follows:

static {
System.loadlibrary ("Game");
}

Otherwise, we'll report the Java COCOSDX couldn ' t load Cocos2dx:findlibrary returned NULL this error
And then it should work.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.