Crashlytics cocos2dx 3.7 + Android Studio

Hi,
I have a project that I have created with cocos2dx 3.7 and compiled it for Android Studio from the command line using the cocos command. I am able to deploy this project on the phone via Android Studio using the Run Command. I was trying to add Crashlytics for crash reporting to my project using Android Studio but i ran into many problems. When I installed the Crashlytics plugin and tried adding it to my project, it said that it could not find any Andoird Module. After changing the buidl.gradle files (I have almost zero knowledge how Gradle Works so please bear with me) I managed to include the Crashlytics files and compile the project using the cocos command line, but now when i ran the project, it crashed on the device saying that it could not find the libcocos2d.so file.
I also tried doing it in an eclipse project, but again i have to use the command line for compiling the project and then Eclipse would create problems as the file R.java was modified externally.

Has anyone integrated this or any other 3rd party sdk into their cocos2dx project in Android studio successfully?If yes, then a tutorial would be very welcome!
Also has anyone been able to build and compile the project from inside Android Studio after they added ndk support to the lastest Android Studio?

I reported this issue to crashlytics a week ago, and we are actively working on finding the issue.

Thatā€™s good to hear! Looking forward to the solution. Have you managed to integrate any other third party sdk successfully(like google play services, Facebook and other various ad sdks).

Iā€™ve been struggling even just to get the template project to run on my device using ā€œcocos runā€. Can you list the steps you took ?

I just created a new project using the cocos new command. After that as mentioned here Cocos2d-x v 3.7 at point number 8 just run the command
cocos run/compile -p android --android-studio
from the console. After that, you can either run using the cocos run command like
cocos run -p android
or just import the project in Android Studio, sync the project and press run. It will run the project on the device or the emulator.
Hope this helps.

I had no issue with gpg (integrated it 6 months ago), still working fine (except for the buggy framework itselfā€¦ so many issues, and now that g+ will be abandoned I donā€™t think google will fix their bugs).
Didnā€™t try facebook yet, I was hoping to use SdkBox so I donā€™t have to do the integration myself :stuck_out_tongue:

I hope SDK box is as easy to integrate as they make it sound :stuck_out_tongue:

I will try as soon as IAP support purchase validation. Iā€™ll add both facebook and IAP at the same time.

let me know how that works out! also if you figure out the issue with Crashlytics let me know about that too!

They are still trying to understand the issue.
Hope it will be solved quickly :wink:

hey any update on this from them?

Hi,

I was able successfully integrate crashlytics thru eclipse for 3.7, but it was big pain :smiley:

Probably it should work also with Android Studio.

Regarding that part:> it crashed on the device saying that it could not find the libcocos2d.so file.

I had same issue, because crashlytics had prebuild libraries for all kind processors (armeabi, x86ā€¦), so itā€™s trying to check also for each prebuild library specific cocos2d.so.

What I did, I manually deleted not used libs from crashlitcs, left only armabi and also pointed in Application.mk to compile project only for armabiā€¦

Have a tryā€¦ planning today to integrate Android Studio + Cocos2d-x 3.8 + Crashlytics

Hi, any update on Crashlytics integration? The Fabric plugin doesnt work for me, Iā€™ve been through manual steps to add crashlytics to gradle but getting:

java.lang.IllegalArgumentException: Crashlytics found an invalid API key: null.

Thanks!

Sorry, no answer.
I think they banned me for asking for an update every couple days :smiley:

Iā€™ll try to ask them once again, but your error seems to be something else, it looks like you misconfigured your key somehow.

Key is stored in Android manifest and if not project.properties file, so itā€™s you config issue for now.

Thanks. Iā€™ve got the key in the manifest and also copied a fabric.properties from another project (for the same organisation so same api secret). Can you give more detail on what you think should go in project.properties?

Double checked project, so regarding key no changes in project.properties but in fabric.properties:

#Contains API Secret used to validate your application. Commit to internal source control; avoid making secret public.
#Sat Jul 11 18:49:24 EEST 2015
apiSecret=MY_KEY
androidBaseManifest=AndroidManifest.xml
enableNDK=true
androidNdkOut=obj
androidNdkLibsOut=libs
externalCSymUpload=true

Thanks @energyy

Iā€™ve been able to get the Fabric (Crashlytics) plugin working with the cocos2d-x project in Android Studio. The problem it was having was that it parses the moduleā€™s .iml file to determine source and resource paths. The iml is an internal project manifest generated by Android Studio from the build.gradle file. This contained references to default paths like ā€˜src/main/javaā€™, ā€˜src/main/resā€™ā€¦ and it was visible in the crashlytics plugin log that it couldnt resolve these non-existent paths and so was giving up (and just bumping me out to the login screen again).

Not sure exactly why these paths are appearing in the .iml file, but it does appear to be caused by how Android Studio is interpreting the gradle file, because here is the fix:

In the appā€™s build.grade (that is generated by the cocos tool with --android-studio flag) the sourceSets config looks like this:

 sourceSets.main {
     java.srcDir "src"
     res.srcDir "res"
     jniLibs.srcDir "libs"
     manifest.srcFile "AndroidManifest.xml"
     assets.srcDir "assets"
 }

Change this to:

sourceSets.main {
    java.srcDirs = ["src"]
    res.srcDirs = ["res"]
    jniLibs.srcDir "libs"
    manifest.srcFile "AndroidManifest.xml"
    assets.srcDirs = ["assets"]
}

And the default non-existent paths are no longer present in the .iml and the Crashlytics plugin is able to work happily with the project. Hope this helps others struggling with the same integration.

Cocos team, may be worth investigating a bit further as there could be other side effects of the invalid paths in the .iml file?

Cheers

1 Like

That cool, will try to use with android studio also. Btw have you integrated crashlytic with ndk support? Itā€™s very usseful when it goest to c++ code crash.

Yeah, Iā€™ve added the ndk config but havent seen it in action yet. Have used Crashlytics for a while on other projects, its a great service.