cocos2d / cocos2d-x

Cocos2d-x is a suite of open-source, cross-platform, game-development tools utilized by millions of developers across the globe. Its core has evolved to serve as the foundation for Cocos Creator 1.x & 2.x.
https://www.cocos.com/en/cocos2d-x
18.22k stars 7.05k forks source link

HttpClient does not work correctly with android 5.0 #9138

Closed minggo closed 9 years ago

minggo commented 9 years ago

Detail information please refer to http://discuss.cocos2d-x.org/t/httpclient-does-not-work-correctly-with-android-5-0/18190/6.

minhtoantm commented 9 years ago

Please fix it as soon as, I'm realy happy when it is fixed. Thanks you.

lokukuol commented 9 years ago

I have the same problem. Please fix it as soon as possible, Thanks you.

ombug commented 9 years ago

HttpClient stop at curl_easy_perform() and can't go on ,please fix the bug quickly.

dumganhar commented 9 years ago

Hi all, we will fix it when we get an Android 5.0 device to reproduce this issue. :)

dumganhar commented 9 years ago

@minhtoantm, @lokukuol ,@ombug, could this issue be reproduced on android 5.0 emulator?

minhtoantm commented 9 years ago

@dumganhar : sorry, I can start my android 5 emulator ( I use genymotion), so I don't know is this issue be reproduced.

hayago commented 9 years ago

@dumganhar : Yes, this issue could be reproduced on android 5.0 emulator.

dumganhar commented 9 years ago

@hayago , thanks. I will check it soon.

jiyucn commented 9 years ago

You guy working on Wangjing Fangheng, right? If possible, I would like to share my Android 5.0 device with you guys. :-)

cashish commented 9 years ago

I encountered the same problem using nexus 5 with android lollipop but with cocos2d-x ver 3.2 there is no callback to onHttpRequestCompleted

dumganhar commented 9 years ago

@jiyucn , thanks for sharing. I have gotten a Nexus 5 with android5.0. I will look inside this issue. :)

dumganhar commented 9 years ago

Hi @redism, @minhtoantm, @lokukuol, @ombug, @hayago, @jiyucn, @cashish I tested this issue. And found that HttpClient works without crash and

    request->setResponseCallback([this](network::HttpClient *sender, network::HttpResponse *response) {
        CCLOG("ResponseCallback called.");
    });

the callback could be invoked. Anything i missed?

minhtoantm commented 9 years ago

This bug don't happend when using cocos2d-x v2.2.5 on Android 5.0

dumganhar commented 9 years ago

I used the test codes written by @hayago here (https://github.com/hayago/HttpClientSample-cocos2dx/blob/master/Classes/AppDelegate.cpp).

dumganhar commented 9 years ago

I'm using the latest codes on github v3 branch. And my device is Nexus 5 Android 5.0.

minhtoantm commented 9 years ago

Can you use ccp-tests project and check? I'm using code in this sample.

dumganhar commented 9 years ago

@minhtoantm ,yes , I also used cpp-tests for testing. But it works ok. :(

minhtoantm commented 9 years ago

I'm using cocos2d-x final v3.2 in website cocos2d-x.org, and ccp-tests don't work. Can you give me a link what you use?

dumganhar commented 9 years ago

@minhtoantm , I used the latest codes on github. You could follow the readme from https://github.com/cocos2d/cocos2d-x to clone the latest codes. I seems that this issue was fixed in the latest codes. :)

minhtoantm commented 9 years ago

Thanks a lot, I will check

dumganhar commented 9 years ago

I will also check this problem in final 3.2. :)

dumganhar commented 9 years ago

Hi all, I have checked the issue by using final3.2 version. Yep, the issue did exist. But I could not reproduce it by the latest codes on github. It seems to be fixed. :) Could someone who got the problem also test it by the latest code on github? Thanks.

minhtoantm commented 9 years ago

Hi @dumganhar: can you check it again? I'm get lastest code from githup, and build ccp-tests, but the issue did exist. I'm using Nexus 5 android 5.0 ( not emulator)

dumganhar commented 9 years ago

@minhtoantm , it's really strange. We're using the same android device but the result is different. What's the ndk version you're using? I'm using ndk-r10c.

minhtoantm commented 9 years ago

@dumganhar : Sorry, I'm using ndk 9c, I will build again now.

minhtoantm commented 9 years ago

@dumganhar : When I use ndk-r10c to build, this issue is fixed. Can you release cocos2d-x v3.3 final? Because using lastest code from github is not stable.

aeonmine commented 9 years ago

I works fine httpclient in v3.3rc0

this is my android.MK

NDK_TOOLCHAIN_VERSION=4.8 APP_STL := gnustl_static APP_CPPFLAGS := -frtti -DCOCOS2D_DEBUG=1 -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char APP_CPPFLAGS += -fexceptions

you can try this

dumganhar commented 9 years ago

@minhtoantm, thanks for testing.

When I use ndk-r10c to build, this issue is fixed.

So it was fixed by using the latest codes on github and using ndk-r10c, right?

Can you release cocos2d-x v3.3 final? Because using lastest code from github is not stable.

We're preparing 3.3rc1 this week, if without any problems, 3.3 final will be released at next weekend. :)

@aeonmine , what's difference of your workaround? Did you find the real reason of this issue? Thanks.

minhtoantm commented 9 years ago

@dumganhar : yes, when I use ndk-r10c with lastest code in github this issue is fixed. I'm wating 3.3 final from you. Thanks a lot.

Virenz commented 9 years ago

@aeonmine , can you tell me why you so set MK file?

lokukuol commented 9 years ago

@dumganhar Can you tell how to compile with ndk-r10c and cocos2dx 3.3rc0 success? I had try the http://www.cocos2d-x.org/news/307,but still have errors.

dumganhar commented 9 years ago

@lokukuol , what kinds of error you met?

lokukuol commented 9 years ago

@dumganhar,hi,I send the errors log to your email.

ombug commented 9 years ago

@dumganhar i'm NDKr10c and cocos2dx3.2rc, but complie lua fail i have referenced the http://cocos2d-x.org/news/307 following the error

C:\cocos2d-x-client\frameworks\runtime-src\proj.android../../cocos2d-x/external/curl/prebuilt/android/armeabi/libcurl.a(sha512-armv4.o): requires unsupported dynamic reloc R_ARM_REL32; recompile with -fPIC C:\cocos2d-x-client\frameworks\runtime-src\proj.android../../cocos2d-x/external/lua/luajit/prebuilt/android/armeabi/libluajit.a(lib_base.o):lib_base.c:function lj_cf_print: error: undefined reference to 'swbuf' C:\cocos2d-x-client\frameworks\runtime-src\proj.android../../cocos2d-x/external/lua/luajit/prebuilt/android/armeabi/libluajit.a(lib_base.o):lib_base.c:function lj_cf_print: error: undefined reference to 'swbuf' C:\cocos2d-x-client\frameworks\runtime-src\proj.android../../cocos2d-x/external/lua/luajit/prebuilt/android/armeabi/libluajit.a(lib_io.o):lib_io.c:function io_file_read: error: undefined reference to '__srget' C:\cocos2d-x-client\frameworks\runtime-src\proj.android../../cocos2d-x/cocos//editor-support/cocostudio/CCComAttribute.cpp:32: error: relocation overflow in R_ARM_THM_CALL C:\cocos2d-x-client\frameworks\runtime-src\proj.android../../cocos2d-x/cocos//editor-support/cocostudio/CCComAudio.cpp:31: error: relocation overflow in R_ARM_THM_CALL ...many error: relocation overflow in R_ARM_THM_CALL ......... Who can help me !

dumganhar commented 9 years ago

+@samuele3hu +@andyque Please help to check the problem @ombug met. Thanks.

lokukuol commented 9 years ago

D:\developer\cocos2d-x-3.3rc0\external/lua/luajit/prebuilt/android/armeabi/libluajit.a(lib_base.o):lib_base.c:function lj_cf_print: error: undefined reference to 'swbuf' D:\developer\cocos2d-x-3.3rc0\external/lua/luajit/prebuilt/android/armeabi/libluajit.a(lib_base.o):lib_base.c:function lj_cf_print: error: undefined reference to 'swbuf' D:\developer\cocos2d-x-3.3rc0\external/lua/luajit/prebuilt/android/armeabi/libluajit.a(lib_io.o):lib_io.c:function io_file_read: error: undefined reference to '__srget' clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation) make.exe: *\ [obj/local/armeabi/liblua_empty_test.so] Error 1

How can solve this?

WenhaiLin commented 9 years ago

@lokukuol You should rebuild luajit. For more information: http://discuss.cocos2d-x.org/t/build-android-base-on-ndk-r10c/18543

ombug commented 9 years ago

I compile lua is success with ndk r10b and cocos2dx 3.2rc0 , but httpclient is not work. Is must use lastest code and nkd r10c ?

WenhaiLin commented 9 years ago

@ombug I think you only need use ndk r10c.

ombug commented 9 years ago

Yes, i compile success with NDK r10c , but Lua is different from C++, follow my steps 1: referenced http://cocos2d-x.org/news/307 2: referenced http://discuss.cocos2d-x.org/t/build-android-base-on-ndk-r10c/18543 3: use cocos2d-x-2.1.5\cocos2dx\platform\third_party\android\prebuilt\libcurl\libs\armeabi\libcurl.a to replace ,I use the lastest code to replace the curl is not work

minggo commented 9 years ago

I think you should use latest libcurl.a here: https://github.com/cocos2d/cocos2d-x-3rd-party-libs-bin.

jiyucn commented 9 years ago

@minggo

I tried to resolve this android 5.0 libcurl issue on our game (Our game is based on cocos 3.2 final release)

I use NDK r9d to build the game and replace libcurl with in your link https://github.com/cocos2d/cocos2d-x-3rd-party-libs-bin. But libcurl still fails to work on Android 5.0.

Am I missing something?

redism commented 9 years ago

I could solve this issue by using latest github cocos2dx + ndk r10c (64bit). But newly compiled binary does not work on Android < 5 devices. (Because of this issue : https://code.google.com/p/android-developer-preview/issues/detail?id=168 )

It may or may not be related to cocos2d-x. I'm looking into this problem now.

redism commented 9 years ago

For anyone who is still stuck, these are steps I successfully resolved this issue, both on Android-5 device and Android<5 devices.

WenhaiLin commented 9 years ago

@redism Thank you.Whether you use gnustl_static + gcc4.9 for build project ? I will check again.

jiyucn commented 9 years ago

Fixed.

  1. Cocos2d-x 3.2 final release.
  2. Build based on android ndk r10c.
  3. Using the lasted liburl from https://github.com/cocos2d/cocos2d-x-3rd-party-libs-bin

Thanks you guys.

redism commented 9 years ago

@Dhilan007 These are Application.mk settings I used.

APP_STL := c++_static NDK_TOOLCHAIN_VERSION := clang

APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char -DCOCOS2D_DEBUG=1 APP_LDFLAGS := -latomic

LIBCXX_FORCE_REBUILD := true APP_ABI := armeabi-v7a APP_PLATFORM := android-9

aeonmine commented 9 years ago

I tested android5.0(L) on cocos2dx_v3.2, it was works fine and then when update to cocos2dx_v3.3 rc0. the BMFont and Httplicent will cause application freeze.

I just copy cocos2dx_v3.2 application.mk to cocos2dx_v3.3 rc0 that both work fine.

Android L (5.0) use art and changed jni role

i will test cocos2dx_v3.3 to find the real reson.

thanks

happyfire commented 9 years ago

Hello, I have make our app compiled against ndk r10c, cocos2dx-3.2, and the latest libcurl prbuild, but when run on android 5.0, there is a error: 02-02 13:34:55.854: A/art(32240): art/runtime/verifier/method_verifier.cc:3321] Check failed: !Thread::Current()->IsExceptionPending() The app can not be lanuched. Anyone can give some help? Thanks!

Update: The problem is only happend when we build on mac platform, using ndk r10c-64 for mac. The things is OK after we use windows platform to build. It is strange.

mdsb100 commented 9 years ago

how about cocos2d-x-2.2.6 ?