Libpomelo + cocos2d-x Development Environment (windows platform development android Program)

Source: Internet
Author: User

And other folders. Currently, only libpomelo compiled in ndk can be modified. But there are still a lot of bugs in it.

Modify deps/jansson/jansson_config.h.in => deps/jansson/jansson_config.h

This h is well configured and I will not write it.

In src/network. c, you need to modify

In the pc_on_tcp_connect function:


Comment out all the log Code in if (status =-1) {}, because req has been free and is used again here.


In the pc_on_notify function:


Comment out the log Code in if (status =-1) {} for the same reason.

Then, if PomeloClient. connect ("127.0.0.1", port) (here is the pseudocode) if the address is 127.0.0.1, I find that crash is used every time on my android phone.

Check the event loop in libuv. Because I usually do not connect to 127.0.0.1, I will not go into details.

The crash locating method is written later.

 


2. Modify cygwin. bat under your cygwin directory to provide path support for future development.

Mine is:


[Plain]
@ Echo off
 
D:
Chdir d: \ cygwin \ bin
 
Set DRIVER =/cygdrive/d
 
Set ANDROID_SDK = % DRIVER %/software/android-sdk-windows
Set VIM_HOME = % DRIVER %/kin-tools/gvim/vim/vim73
Set ANT_HOME = % DRIVER %/ws_eclipse/ant/apache-ant-1.9.0
Set NDK_ROOT = % DRIVER %/software/android-ndk-r8d-windows
Set NDK_TOOLCHAINS_0 = % NDK_ROOT %/toolchains/arm-linux-androideabi-4.7/prebuilt/windows/arm-linux-androideabi/bin
Set NDK_TOOLCHAINS_1 = % NDK_ROOT %/toolchains/arm-linux-androideabi-4.7/prebuilt/windows/bin
Set NDK_TOOLCHAINS = % NDK_TOOLCHAINS_0 %; % NDK_TOOLCHAINS_1 %;
 
Set extpath = % ANDROID_HOME %/tools; % ANT_HOME %/bin; % ANDROID_SDK %/platform-tools; % ANDROID_SDK %/tools; % VIM_HOME %
Set extpath = % NDK_TOOLCHAINS %; % extpath %
 
Set path = % extpath %; % path %
 
Set cc_root = % DRIVER %/software/cocos2d-2.1rc0-x-2.1.2/cocos2d-2.1rc0-x-2.1.2
Set cc_pomelo_android = % cc_root %/cocos2dx/platform/third_party/android/prebuilt
Set ws_proj = % cc_root %/projects/PomeloClientDemo/proj. android
Set ws_proj_so = % ws_proj %/obj/local/armeabi/libcocos2dcpp. so
 
Set addr2line = % NDK_TOOLCHAINS_1 %/ arm-linux-androideabi-addr2line
Set objdump = % NDK_TOOLCHAINS_1 %/arm-linux-androideabi-objdump
 
Bash -- login-I

@ Echo off

D:
Chdir d: \ cygwin \ bin

Set DRIVER =/cygdrive/d

Set ANDROID_SDK = % DRIVER %/software/android-sdk-windows
Set VIM_HOME = % DRIVER %/kin-tools/gvim/vim/vim73
Set ANT_HOME = % DRIVER %/ws_eclipse/ant/apache-ant-1.9.0
Set NDK_ROOT = % DRIVER %/software/android-ndk-r8d-windows
Set NDK_TOOLCHAINS_0 = % NDK_ROOT %/toolchains/arm-linux-androideabi-4.7/prebuilt/windows/arm-linux-androideabi/bin
Set NDK_TOOLCHAINS_1 = % NDK_ROOT %/toolchains/arm-linux-androideabi-4.7/prebuilt/windows/bin
Set NDK_TOOLCHAINS = % NDK_TOOLCHAINS_0 %; % NDK_TOOLCHAINS_1 %;

Set extpath = % ANDROID_HOME %/tools; % ANT_HOME %/bin; % ANDROID_SDK %/platform-tools; % ANDROID_SDK %/tools; % VIM_HOME %
Set extpath = % NDK_TOOLCHAINS %; % extpath %

Set path = % extpath %; % path %

Set cc_root = % DRIVER %/software/cocos2d-2.1rc0-x-2.1.2/cocos2d-2.1rc0-x-2.1.2
Set cc_pomelo_android = % cc_root %/cocos2dx/platform/third_party/android/prebuilt
Set ws_proj = % cc_root %/projects/PomeloClientDemo/proj. android
Set ws_proj_so = % ws_proj %/obj/local/armeabi/libcocos2dcpp. so

Set addr2line = % NDK_TOOLCHAINS_1 %/ arm-linux-androideabi-addr2line
Set objdump = % NDK_TOOLCHAINS_1 %/arm-linux-androideabi-objdump

Bash -- login-I

 

3. In cygwin's shell
Cd $ ws_proj;

Execute the compilation:

./Build_native.sh

If you are lucky, so compilation is successful.

If you are not lucky, it may be that your android project version is too low, at least android-2.3.3. Otherwise, the classes related to the thread lock will not be defined, or the barrier or something.

 


4. After so compilation is successful, generate an apk for testing.

Cd $ ws_proj;

Ant debug install; install it to the default android device.

 


5. Open logcat before running

Adb logcat-c & adb logcat

 


6. Run your program.

If there is a crash in so. You can use addr2line or objjump.

I 'd like to write about it. There are already a lot of online tutorials. Forget it.

 

 

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.