[Critical] Support for 64bit on cocos2d-x on Android!

I know cocos2d-x 2.x less.

you can check the external prebuilt libs firstly, if the prebuilt libs only include arm 32-bit (armeabi/armeabi-v7a) arch, you will need to compile arm64-v8a arch manually.

I will be porting v2.2.6 to arm64-v8a for our applications. I can post a how-to if it ends up being complex or help people write patches for their branches.

Likely if you are using v2.2.6 for iOS currently you’ve already fixed a bunch of the size_t and syntax issues and your main problem here will be stuff like …\cocos2dx\platform\third_party\android\prebuilt/libjpeg/libs/arm64-v8a/libjpeg.a doesn’t exist in the v2.2.6 source.

3 Likes

@slackmoehrle I think the one question we could use engineering support on would be if there are any known compatibility issues with libz, libpng, libjpeg or libcurl between the version that ships with v2.2.6 and 3.17

Do you have some guide how to update to 64 bit step by step?

Same, please give some step by step guidance.

I did 3 things:

  1. in Application.mk:
    APP_ABI := armeabi armeabi-v7a arm64-v8a

  2. In gradle.properties:
    PROP_APP_ABI=armeabi-v7a:arm64-v8a

  3. In build.gradle(Module: myapp):
    abiFilters 'armeabi-v7a', 'arm64-v8a'

Built the project and I now see both the libs when I unzip the apk file. I hope this is all there is to it :slight_smile:

image

2 Likes

Is it v2.2.6? You use Android Studio?.

In my case, Use Eclipse. Ndk version is r10e… :frowning:

1 Like

Yes, I use Android Studio. Cocos2d-x 3.17.
Migrated away from Eclipse a few years ago. Can’t remember anymore. Sorry I’m not able to help.

I vote for support x86_64 in next version. Number of chromebooks slowly growing…

Also it would be nice to recompile everything with latest ndk (currently prebuilds are compiled with ndk16)

2 Likes

There has another thread to upgrade Eclipse to Android Studio.
I managed to upgrade from Eclipse IDE to Android Studio a few months ago for my v2.2.6 games. Not so difficult to do. Let me know and I can share more instructions.

The point is how v2.2.6 support android 64 bits. Any plan from cocos2dx team to support it as v2.2.6 is the official downloadable version? Can we use the v3.17 64 bits libraries to link with v2.2.6?

The worst case is upgraded all v2.2.6 to latest v3.17 version. Any upgrade guideline or sample for reference?

I try to support 64bit on v2.2.6… but failed… :frowning:
I can’t find libwebsocket.a for arm64-v8a on v2.2.6

I want to cocos2dx team support :slight_smile:

if you donot libwebsocket, just remove it.

I just search and found the following link has those libraries for arm64-v8a. Do you think we can use it?

Thanks, I removed it(I use HttpClient…etc…). Build Done!!

But crash… :frowning:

2019-02-04 22:52:28.720 15369-15528/? A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x7c0000063c in tid 15528 (GLThread 2308), pid 15369 (stfantasy1super)
2019-02-04 22:52:28.825 15578-15578/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2019-02-04 22:52:28.825 15578-15578/? A/DEBUG: Build fingerprint: ‘google/bullhead/bullhead:8.1.0/OPM2.171019.029/4657601:user/release-keys’
2019-02-04 22:52:28.825 15578-15578/? A/DEBUG: Revision: ‘rev_1.0’
2019-02-04 22:52:28.825 15578-15578/? A/DEBUG: ABI: ‘arm64’
2019-02-04 22:52:28.825 15578-15578/? A/DEBUG: pid: 15369, tid: 15528, name: GLThread 2308 >>> com.sosc.firstfantasy1super <<<
2019-02-04 22:52:28.825 15578-15578/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x7c0000063c
2019-02-04 22:52:28.825 15578-15578/? A/DEBUG: x0 0000007c00000000 x1 0000000000200002 x2 0000007c8dbff484 x3 0000000000000002
2019-02-04 22:52:28.825 15578-15578/? A/DEBUG: x4 0000007c8dbff280 x5 0000007c901d8e38 x6 0000007d3232f000 x7 0000000000000000
2019-02-04 22:52:28.825 15578-15578/? A/DEBUG: x8 00000000000000c8 x9 0000007c9705b9d4 x10 0000007c8dbff2d0 x11 0000000000000008
2019-02-04 22:52:28.825 15578-15578/? A/DEBUG: x12 0000007c90173e60 x13 ffffffffa3a96d36 x14 0006d8f718000000 x15 003b9aca00000000
2019-02-04 22:52:28.825 15578-15578/? A/DEBUG: x16 0000007c97219428 x17 0000007d2f9012f0 x18 0000000000008c38 x19 0000007c00000000
2019-02-04 22:52:28.825 15578-15578/? A/DEBUG: x20 0000007c97233650 x21 0000000000000000 x22 0000007c900f0380 x23 0000007c956dde30
2019-02-04 22:52:28.825 15578-15578/? A/DEBUG: x24 0000007c8dbff488 x25 0000007c956dde50 x26 0000007c972337d0 x27 0000007c96c3018c
2019-02-04 22:52:28.825 15578-15578/? A/DEBUG: x28 0000007c970457a0 x29 0000007c8dbff400 x30 0000007c96c2fa1c
2019-02-04 22:52:28.826 15578-15578/? A/DEBUG: sp 0000007c8dbff3a0 pc 0000007c96d6ad9c pstate 0000000060000000
2019-02-04 22:52:28.829 15578-15578/? A/DEBUG: backtrace:
2019-02-04 22:52:28.829 15578-15578/? A/DEBUG: #00 pc 0000000000526d9c /data/app/com.sosc.firstfantasy1super-o6ol-Iz5LAVgX16ZCUIqaA==/lib/arm64/libcocos2dcpp.so
2019-02-04 22:52:28.829 15578-15578/? A/DEBUG: #01 pc 00000000003eba18 /data/app/com.sosc.firstfantasy1super-o6ol-Iz5LAVgX16ZCUIqaA==/lib/arm64/libcocos2dcpp.so
2019-02-04 22:52:28.829 15578-15578/? A/DEBUG: #02 pc 0000000000067d0c /system/lib64/libc.so (__pthread_start(void*)+36)
2019-02-04 22:52:28.830 15578-15578/? A/DEBUG: #03 pc 000000000001eba4 /system/lib64/libc.so (__start_thread+68)
2019-02-04 22:52:31.993 590-590/? E//system/bin/tombstoned: Tombstone written to: /data/tombstones/tombstone_09
2019-02-04 22:52:32.099 427-427/? E/lowmemorykiller: Error writing /proc/15369/oom_score_adj; errno=22
2019-02-04 22:52:32.157 766-9813/? E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 68)
2019-02-04 22:52:32.165 766-1248/? E/InputDispatcher: channel ‘a985cf com.sosc.firstfantasy1super/com.sosc.firstfantasy1super.FirstFantasy (server)’ ~ Channel is unrecoverably broken and will be disposed!
2019-02-04 22:52:32.166 428-460/? E/SurfaceFlinger: Failed to find layer (SurfaceView - com.sosc.firstfantasy1super/com.sosc.firstfantasy1super.FirstFantasy#0) in layer parent (no-parent).

Does it crash at start?

Please check this line https://github.com/cocos2d/cocos2d-x/blob/8fc3b7b4064b107d85c15a4895d08e9ad335b5a8/templates/cpp-template-default/proj.android/app/jni/hellocpp/main.cpp#L39

is x86 & x86_64 for android phones or chrome books or both ?

Can you share what you have done? So, I will try to compile and test it in v2.2.6 sample project and share the result later. Thanks.

My main.cpp is …

#include “AppDelegate.h”

#include “cocos2d.h”

#include “CCEventType.h”

#include “platform/android/jni/JniHelper.h”

#include <jni.h>

#include <android/log.h>

#define LOG_TAG “main”

#define LOGD(…) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,VA_ARGS)

using namespace cocos2d;

extern “C”

{

jint JNI_OnLoad (JavaVM *vm, void *reserved)

{

JniHelper::setJavaVM(vm);

return JNI_VERSION_1_4;

}

void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit (JNIEnv* env, jobject thiz, jint w, jint h)

{

if (!CCDirector::sharedDirector()->getOpenGLView())

{

CCEGLView *view = CCEGLView::sharedOpenGLView();

view->setFrameSize(w, h);

AppDelegate *pAppDelegate = new AppDelegate();

CCApplication::sharedApplication()->run();

}

else

{

ccGLInvalidateStateCache();

CCShaderCache::sharedShaderCache()->reloadDefaultShaders();

ccDrawInit();

CCTextureCache::reloadAllTextures();

CCNotificationCenter::sharedNotificationCenter()->postNotification(EVENT_COME_TO_FOREGROUND, NULL);

CCDirector::sharedDirector()->setGLDefaultValues();

}

}

}

I have to change it??

Yes, please merge or just replace from latest cocos2d

It’s not working.
Auctually, Build is successed, I can see first scene…
But few second later. Game is crash…Same log… :frowning:

I don’t know why… :frowning: