50 EUR giveaway for Firebase SDK integration

50 EUR giveaway for Firebase SDK integration
0.0 0



It seems no one jet implemented Cocos2d-x with Firebase.

So I decided to make little motivation and giving 50 eur to someone who will make sample project with Cocos2d-x 3.11 C++ & Firebase latest SDK for IOS and Android.

If more info is needed ask me there.



Email me : frog.vn.2016@gmail.com for talk about that :smile:


So basically you could make sample project for Firebase Analytics C++ SDK - integrate it to Cocos2d-x “Hello world” project for IOS & Android. Trigger Analytics initialization and send one event to show in Firebase dashboard.

Sounds easy?:slight_smile:


@energy, thanks for introducing firebase, it looks like i can totally use this with one of my current application project using cocos2d-x and openCV. Any updates on this one?


I did on iOS (just use cocoa pods, simple). But I can’t do it on android, because it requires Gradle. Though you can try that: https://github.com/dandar3/android-google-firebase-common using Eclipse (I personally couldn’t make it because some Firebase packages were strangely missing).


on iOS you managed it for cocos2d-x project or just IOS project? Regarding missing packages if it was gradle you probably didn’t added repository url for files.


Well, I’m using older firebase sdk (android + ios) in few cocos2d-x apps. Only problem is to transfer data between Objc/c++ and JNI(Java)/c++ so instead I just send json string and parse it in c++ code.
I didn’t have time to try new c++ sdk, which is beta anyway.
I wanted to migrate to new firebase sdk and I succeded on iOS, but on android I have eclipse project, because gradle isn’t just a solution for now (however it’s close, see topic about cmake).


Checking status if someone managed to make it work with new SDK and ready to receive bonus?


Directly with c++ sdk?


So basically you still need to add native sdks to IOS and Android and then on top of it attach c++ sdk. Itwould be great to start atleast with native sdk initialization in cocos2d-x and then we can have a look and try to attach c++ sdk. for android version we should use gradle script.


Any ideas how to call this one on Android for Firebase SDK?

// Create the Firebase app.
::firebase::App* app =
                            GetJniEnv(), GetActivity());

// Initialize the AdMob library.

How I should implement functions GetJniEnv(), GetActivity() on Android, where I should declare them, any ideas?


@energyy for GetJniEnv you can use cocos JniHelper::getEnv method.


@TheCodez thanks for pointing any idea for GetActivity() ?


@TheCodez I’m not entirely sure, but something like the following.
Create a static instance field of your activity call it sActivity and initialize it with this in your onCreate function

In C++ use something like this

jobject GetActivity() 
    JNIEnv* env = JniHelper::getEnv();
    jclass activityClass = env->FindClass("com/example/YourActivityName");
    //Get the Activity field
    jfieldID activityField = env->GetStaticFieldID(activityClass, "sActivity","Lcom/example/YourActivityName;");
    //Get the Activity object
    jobject activityObject = env->GetStaticObjectField(activityClass, activityField);

    return activityObject;

Note: I wrote this code without a IDE, so it might not work nor will it compile successfully. Hope its a good starting point anyways.



I was trying to use your code sample to get working Firebase, but seems something getting wrong as app is crashing when running.

I created repository inside github to have a try:

So what I’m done for Android part:

  1. Placed in cocos2d/external Firebase SDK “firebase_cpp_sdk”
    Added there Android.mk with Firebase core and Analytics

  2. Modified in project /app folder Android.mk -> included Firebase SDK

  3. Modified project Gradle to add native Firebase SDK

  4. Modified AppActivity added sActivity variable which hold Activity.

  5. Added to JNIHelper function GetActivity to get Activity.

  6. Added Firebase initialization code to AppDelegate.cpp

     //LogMessage("Initialize the Analytics library");

    #if defined(ANDROID)
    app = ::firebase::App::Create(::firebase::AppOptions(), cocos2d::JniHelper::getEnv(),
    app = ::firebase::App::Create(::firebase::AppOptions());
    #endif // defined(ANDROID)

Pretty sure something doing wrong or need additional initializations on Android side.

Can you please have a look on this?:slight_smile:


@energyy did you compile using cocos console before running in Android Studio? If you did, then I have a different idea that should work.


@TheCodez yes I compiled before, in case I’m using android studio + gradle.


@energyy I will create a pull request the next day or so, that might fix your problem. Don’t have much time atm.


Ok, thanks:) waiting then for it


@energyy sent you a pr, please test