Crashlytics cocos2dx 3.7 + Android Studio

CMON :smiley: this already was solved - check previous posts. We integrated same way in many game and it works.

My mistake :smile:, i just use version 2.5.5 and it works

@energyy,
i have done the gradle setup as described by you in your previous posts. i am getting crash report from java but not getting ndk crash reports. please help me how to enable ndk crash report.
thanks in advance.

Have you initialized app this way in AppActivity?

Also don’t forget that u need to run command:

./gradlew crashlyticsUploadSymbolsRelease

or

./gradlew crashlyticsUploadSymbolsDebug

depends if you trying debug release or debug APK - it allows to show more detailed log about C++ error. . This command should be executed from proj.android-studio folder in terminal. Also it could be that you crashing app in to fatal way in C++ try different crash statement to see if you get it or not.

Yes i have initialized app in AppActivity using Fabric.with(this, new Crashlytics(), new CrashlyticsNdk());
I am using ./gradlew crashlyticsUploadSymbolsRelease in android terminal.
I am running my app through console using cocos run -p android --android-studio.
I am using this sequence to run the apk
Step 1: sync the gradle
Step 2: run ./gradlew crashlyticsUploadSymbolsRelease in android terminal
Step 3: run using cocos run -p android --android-studio

I am not used to android studio.
Please help me if i am doing correct or not.

I think it compiling by default in debug mode, so you need to run SymbolsDebug …

Also check terminal console if everything really works maybe you getting at some point error. Try to delete from app folder obj and libs folders and make new full recompile.

I have run with ./gradlew crashlyticsUploadSymbolsDebug, but still not getting any log.
I am checking for nullpointer exception and getting Fatal error in console.

method is
{

Sprite * spr = Sprite:create(“xyz.png”);
spr->setPosition(Vec2(100,100));
this->addChild(spr);
}

The xyz.png image is not added in resources and getting cocos console “file not found”.
and after Sprite::create , on setPosition Fatal error is shown in console.

Can you please tell me that am i doing correct to generate the crash or not.

better try to divide to zerro or try set object null and then try to do something with that.

I think missing resource was one of cases which not appearing in NDK logs.

Sprite * spr = Sprite:create(“xyz.png”);
when cuz.png is not found then it returns null.
so using sir for setPosition(), it is null pointer check.
but it is giving Fatal error.
Do you have any demo or helpful docs to integrate crashlytics with cocos2dx.

Hello, I have integrated NDK Crashlytics into my cocos2d-x app. It is working fine for device having API level 19,
I am able to see complete crash logs of c++ code. But when I run same app on device having API 23,
It does not provide useful info about crash, although its showing the crash (as Unknown Error), )but not detailed info.
When I check the log it is printing like:-

google-breakpad: ### ### ### ### ### ### ### ### ### ### ### ### ###
com.company.test W/google-breakpad: Chrome build fingerprint:
com.company.test W/google-breakpad: 1.0.5
Kindly help me with this. How can I get detailed info about logs for device having API level higher than 19.

This is a same situation in my app.

hi, Can you suggest me either solution or any alternative for this problem?

I have not done that yet.
I sent an email to Fabric and I’m waiting for a response.

@energyy, isn’t the android.splits abi limited the app deployment to only specific devices with that cpu architecture ?

I have doubts if the output of such build would on all cpu arch device.

yes, u should use in abi split only compiled architectures otherwise app will crash. ABI split should match Application.mk set abi

I tried with your above instructions but it’s still not working. It always says:
error: package com.crashlytics.android does not exist

I’m doing like this:

  1. ./gradlew crashlyticsUploadSymbolsDebug
  2. cocos run -p android --android-studio

Could you please check what’s went wrong here ?

-----------this is my build.gradle from app folder:-----------------
apply plugin: ‘com.android.application’
apply plugin: ‘io.fabric’

buildscript {
repositories {
jcenter()
maven { url ‘https://maven.fabric.io/public’ }
}
dependencies {
classpath ‘io.fabric.tools:gradle:1.+’
}
}

repositories {
jcenter()
maven { url ‘https://maven.fabric.io/public’ }
}

android {
compileSdkVersion 25
buildToolsVersion ‘25.0.0’

defaultConfig {
    applicationId "my.package.id"
    minSdkVersion 10
    targetSdkVersion 23
    versionCode 9
    versionName "1.8"
    multiDexEnabled true
}

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

splits {
    abi {
        enable true
        reset()
        include 'armeabi'
        universalApk false
    }
}

signingConfigs {
   release {
        if (project.hasProperty("RELEASE_STORE_FILE")) {
            storeFile file(RELEASE_STORE_FILE)
            storePassword RELEASE_STORE_PASSWORD
            keyAlias RELEASE_KEY_ALIAS
            keyPassword RELEASE_KEY_PASSWORD
        }
    }
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        if (project.hasProperty("RELEASE_STORE_FILE")) {
            signingConfig signingConfigs.release
        }
    }
}

}

crashlytics {
enableNdk true
androidNdkOut ‘obj’
androidNdkLibsOut ‘libs’
}

dependencies {
compile fileTree(dir: ‘libs’, include: [’*.jar’])
compile project(’:libcocos2dx’)

compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
    transitive = true;
}
compile('com.crashlytics.sdk.android:crashlytics-ndk:1.1.6@aar') {
    transitive = true;
}

}

task cleanAssets(type: Delete) {
delete ‘assets’
}
task copyAssets(type: Copy) {
from ‘…/…/Resources’
into ‘assets’
}

android {
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}

clean.dependsOn cleanAssets
preBuild.dependsOn copyAssets

I dont like how looks your start of script, add this part until Android { tag, it seems incorrect order of commands u have.

import org.apache.tools.ant.taskdefs.condition.Os

buildscript {
    repositories {
        jcenter()
        maven { url 'https://maven.fabric.io/public'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        // The Fabric Gradle plugin uses an open ended version to
        // react quickly to Android tooling updates
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
    jcenter()
    maven { url 'https://maven.fabric.io/public' }
}

I corrected the order but still it didn’t work. :frowning:

paste your log ,and build.gradle - also which cocos version u using

Below are the details:

cocos version: 3.14.1 C++
used plugins: sdkbox>appodeal

build.gradle :

buildscript {
    repositories {
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    jcenter( )
    maven { url 'https://maven.fabric.io/public' }
}

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.0'

    defaultConfig {
        applicationId "com.js.mygame"
        minSdkVersion 10
        targetSdkVersion 23
        versionCode 9
        versionName "1.8"
        multiDexEnabled true
    }

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

    splits {
        abi {
            enable true
            reset()
            include 'armeabi'
            universalApk false
        }
    }

    signingConfigs {

       release {
            if (project.hasProperty("RELEASE_STORE_FILE")) {
                storeFile file(RELEASE_STORE_FILE)
                storePassword RELEASE_STORE_PASSWORD
                keyAlias RELEASE_KEY_ALIAS
                keyPassword RELEASE_KEY_PASSWORD
            }
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            if (project.hasProperty("RELEASE_STORE_FILE")) {
                signingConfig signingConfigs.release
            }
        }
    }
}

crashlytics {
    enableNdk true
    androidNdkOut 'obj'
    androidNdkLibsOut 'libs'
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])

    // for crashlytics
    compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
        transitive = true;
    }
    compile('com.crashlytics.sdk.android:crashlytics-ndk:1.1.6@aar') {
        transitive = true;
    }

    compile project(':libcocos2dx')

}

task cleanAssets(type: Delete) {
    delete 'assets'
}
task copyAssets(type: Copy) {
    from '../../Resources'
    into 'assets'
}

android {
    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }
}


clean.dependsOn cleanAssets
preBuild.dependsOn copyAssets

log from command ‘./gradlew crashlyticsUploadSymbolsDebug’:

Jeevans-iMac:proj.android-studio Jeevan$ ./gradlew crashlyticsUploadSymbolsDebug
Incremental java compilation is an incubating feature.
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
:mygame:copyAssets UP-TO-DATE
:mygame:preBuild UP-TO-DATE
:mygame:preDebugBuild UP-TO-DATE
:mygame:checkDebugManifest
:mygame:preDebugAndroidTestBuild UP-TO-DATE
:mygame:preReleaseBuild UP-TO-DATE
:mygame:prepareComAndroidSupportMultidex101Library
:mygame:prepareComCrashlyticsSdkAndroidAnswers1313Library
:mygame:prepareComCrashlyticsSdkAndroidBeta125Library
:mygame:prepareComCrashlyticsSdkAndroidCrashlytics268Library
:mygame:prepareComCrashlyticsSdkAndroidCrashlyticsCore2317Library
:mygame:prepareComCrashlyticsSdkAndroidCrashlyticsNdk116Library
:mygame:prepareIoFabricSdkAndroidFabric1317Library
:cheetah_lib:preBuild UP-TO-DATE
:cheetah_lib:preReleaseBuild UP-TO-DATE
:cheetah_lib:checkReleaseManifest
:cheetah_lib:prepareReleaseDependencies
:cheetah_lib:compileReleaseAidl UP-TO-DATE
:cheetah_lib:compileReleaseNdk UP-TO-DATE
:cheetah_lib:compileLint UP-TO-DATE
:cheetah_lib:copyReleaseLint UP-TO-DATE
:cheetah_lib:mergeReleaseShaders UP-TO-DATE
:cheetah_lib:compileReleaseShaders UP-TO-DATE
:cheetah_lib:generateReleaseAssets UP-TO-DATE
:cheetah_lib:mergeReleaseAssets UP-TO-DATE
:cheetah_lib:mergeReleaseProguardFiles UP-TO-DATE
:cheetah_lib:packageReleaseRenderscript UP-TO-DATE
:cheetah_lib:compileReleaseRenderscript UP-TO-DATE
:cheetah_lib:generateReleaseResValues UP-TO-DATE
:cheetah_lib:generateReleaseResources UP-TO-DATE
:cheetah_lib:packageReleaseResources UP-TO-DATE
:cheetah_lib:processReleaseManifest UP-TO-DATE
:cheetah_lib:generateReleaseBuildConfig UP-TO-DATE
:cheetah_lib:processReleaseResources UP-TO-DATE
:cheetah_lib:generateReleaseSources UP-TO-DATE
:cheetah_lib:incrementalReleaseJavaCompilationSafeguard UP-TO-DATE
:cheetah_lib:javaPreCompileRelease
:cheetah_lib:compileReleaseJavaWithJavac UP-TO-DATE
:cheetah_lib:processReleaseJavaRes UP-TO-DATE
:cheetah_lib:transformResourcesWithMergeJavaResForRelease UP-TO-DATE
:cheetah_lib:transformClassesAndResourcesWithSyncLibJarsForRelease UP-TO-DATE
:cheetah_lib:mergeReleaseJniLibFolders UP-TO-DATE
:cheetah_lib:transformNativeLibsWithMergeJniLibsForRelease UP-TO-DATE
:cheetah_lib:transformNativeLibsWithStripDebugSymbolForRelease UP-TO-DATE
:cheetah_lib:transformNativeLibsWithSyncJniLibsForRelease UP-TO-DATE
:cheetah_lib:bundleRelease UP-TO-DATE
:gps:preBuild UP-TO-DATE
:gps:preReleaseBuild UP-TO-DATE
:gps:checkReleaseManifest
:gps:prepareReleaseDependencies
:gps:compileReleaseAidl UP-TO-DATE
:gps:compileReleaseNdk UP-TO-DATE
:gps:compileLint UP-TO-DATE
:gps:copyReleaseLint UP-TO-DATE
:gps:mergeReleaseShaders UP-TO-DATE
:gps:compileReleaseShaders UP-TO-DATE
:gps:generateReleaseAssets UP-TO-DATE
:gps:mergeReleaseAssets UP-TO-DATE
:gps:mergeReleaseProguardFiles UP-TO-DATE
:gps:packageReleaseRenderscript UP-TO-DATE
:gps:compileReleaseRenderscript UP-TO-DATE
:gps:generateReleaseResValues UP-TO-DATE
:gps:generateReleaseResources UP-TO-DATE
:gps:packageReleaseResources UP-TO-DATE
:gps:processReleaseManifest UP-TO-DATE
:gps:generateReleaseBuildConfig UP-TO-DATE
:gps:processReleaseResources UP-TO-DATE
:gps:generateReleaseSources UP-TO-DATE
:gps:incrementalReleaseJavaCompilationSafeguard UP-TO-DATE
:gps:javaPreCompileRelease
:gps:compileReleaseJavaWithJavac UP-TO-DATE
:gps:processReleaseJavaRes UP-TO-DATE
:gps:transformResourcesWithMergeJavaResForRelease UP-TO-DATE
:gps:transformClassesAndResourcesWithSyncLibJarsForRelease UP-TO-DATE
:gps:mergeReleaseJniLibFolders UP-TO-DATE
:gps:transformNativeLibsWithMergeJniLibsForRelease UP-TO-DATE
:gps:transformNativeLibsWithStripDebugSymbolForRelease UP-TO-DATE
:gps:transformNativeLibsWithSyncJniLibsForRelease UP-TO-DATE
:gps:bundleRelease UP-TO-DATE
:libcocos2dx:preBuild UP-TO-DATE
:libcocos2dx:preReleaseBuild UP-TO-DATE
:libcocos2dx:checkReleaseManifest
:libcocos2dx:prepareReleaseDependencies
:libcocos2dx:compileReleaseAidl UP-TO-DATE
:libcocos2dx:compileReleaseNdk UP-TO-DATE
:libcocos2dx:compileLint UP-TO-DATE
:libcocos2dx:copyReleaseLint UP-TO-DATE
:libcocos2dx:mergeReleaseShaders UP-TO-DATE
:libcocos2dx:compileReleaseShaders UP-TO-DATE
:libcocos2dx:generateReleaseAssets UP-TO-DATE
:libcocos2dx:mergeReleaseAssets UP-TO-DATE
:libcocos2dx:mergeReleaseProguardFiles UP-TO-DATE
:libcocos2dx:packageReleaseRenderscript UP-TO-DATE
:libcocos2dx:compileReleaseRenderscript UP-TO-DATE
:libcocos2dx:generateReleaseResValues UP-TO-DATE
:libcocos2dx:generateReleaseResources UP-TO-DATE
:libcocos2dx:packageReleaseResources UP-TO-DATE
:libcocos2dx:processReleaseManifest UP-TO-DATE
:libcocos2dx:generateReleaseBuildConfig UP-TO-DATE
:libcocos2dx:mergeReleaseResources UP-TO-DATE
:libcocos2dx:processReleaseResources UP-TO-DATE
:libcocos2dx:generateReleaseSources UP-TO-DATE
:libcocos2dx:incrementalReleaseJavaCompilationSafeguard UP-TO-DATE
:libcocos2dx:javaPreCompileRelease
:libcocos2dx:compileReleaseJavaWithJavac
:libcocos2dx:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
/mygame/cocos2d/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java:55: error: package com.crashlytics.android does not exist
import com.crashlytics.android.Crashlytics;
                              ^
/mygame/cocos2d/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java:56: error: package com.crashlytics.android.ndk does not exist
import com.crashlytics.android.ndk.CrashlyticsNdk;
                                  ^
/mygame/cocos2d/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java:57: error: package io.fabric.sdk.android does not exist
import io.fabric.sdk.android.Fabric;
                            ^
/mygame/cocos2d/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java:267: error: cannot find symbol
        Fabric.with(this, new Crashlytics(), new CrashlyticsNdk());
                              ^
  symbol:   class Crashlytics
  location: class Cocos2dxActivity
/mygame/cocos2d/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java:267: error: cannot find symbol
        Fabric.with(this, new Crashlytics(), new CrashlyticsNdk());
                                                 ^
  symbol:   class CrashlyticsNdk
  location: class Cocos2dxActivity
/mygame/cocos2d/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java:267: error: cannot find symbol
        Fabric.with(this, new Crashlytics(), new CrashlyticsNdk());
        ^
  symbol:   variable Fabric
  location: class Cocos2dxActivity
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
6 errors
:libcocos2dx:compileReleaseJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':libcocos2dx:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 5.861 secs
Jeevans-iMac:proj.android-studio Jeevan$