android - Firebase Crashlytics custom log does not appear in the console

android - Firebase Crashlytics custom log does not appear in the console

Nandita Maud Author: Nandita Maud Date: 2022-08-20
android - Firebase Crashlytics custom log does not appear in the console

All you need to know about android - Firebase Crashlytics custom log does not appear in the console , in addintion to android - Does the number of users ( not logged out ) on app equal no of simultaneous connections on firebase? , android - Firebase Crashlytics Console not showing crashes on neither new or old builds anymore , android - ProgressDialog does not want to update the message , android - Why are the custom events of Firebase analytics not shown on dashboard?

  1. android - Firebase Crashlytics custom log does not appear in the console
  2. Question:

    I've been testing Firebase Crashlytics and even though the normal crash report works right I can't success trying to generate a custom as it says the documentation.

    Crashlytics.log(msg); 
    

    I also would like to know wether setting the user identifier for Crashlytics can be done for any crash (according to the doc I've understood that it's possible) with

    void Crashlytics.setUserIdentifier(String identifier); 
    

    and how it would have to be done, because it does neither work to me, I can't see anything on the Firebase crashlytics console.

    Thanks in advance!


    Solution 1:

    For a better understanding, when you collect data with

    FirebaseCrashlytics.getInstance().log("Test w(text)")
    FirebaseCrashlytics.getInstance().log("Test e(text)")
    

    you will get NO new non-fatal crash report in Firebase crashlytics. But follow up by a

    FirebaseCrashlytics.getInstance().recordException(RunTimeException("Test e(throwable)"))
    

    it will send this error : enter image description here

    with this additional log entries within this error

    enter image description here

    Solution 2:

    The logging mechanism of Crashlytics isn't built for normal logging.

    The logs that you put will show in crash reports, not as stand alone logs. Same goes for the user identifier information.

    Try forcing a crash, you should see the logs captured before the crash in the crash report. If you want normal logging, you should look into Firebase analytics, it'll help you keep track of regular events and other analytics data.

    Solution 3:

    This worked for me.

    Crashlytics.log(message);
    Crashlytics.logException(exception);
    

    Edit: I had missed this explanation.

  3. android - Does the number of users ( not logged out ) on app equal no of simultaneous connections on firebase?
  4. Question:

    I have an android app developed and I am expecting more than a 100 users.The app does have a logout button but I doubt any user would logout,they would instead push it to background. So my question is if I have 150 users ( logged in ,but in background) mean that I have 150 simultaneous connections ? I did read a few questions on simultaneous connections , but can someone be more accurate on what is a concurrent connection. 150 users - logged in (background) - open app at different times - ? If this is going to exceed the free plan on firebase , how do i prevent it?.I use email/password for login.


    Solution 1:

    When you start an app that uses the Firebase Database, it creates a persistent connection to the Firebase server. This counts as one active connection on the back-end.

    The connection can be broken when:

    1. the user hasn't written any data and doesn't have any active listeners for a few minutes (currently 5 minutes, but that could change).
    2. you call goOffline() in your code

    Whether the app is in the foreground or background is irrelevant to the Firebase SDK. But you could use Android life-cycle events (such as onPause()) to detect such transitions and remove your listeners (to get to condition 1).

    Also: when your app is backgrounded, the Android operating system might close the connection from the client to the Firebase back-end at any time. When it does this depends on the version and flavor of Android your device has.

    A final option (as fellow Firebaser Doug pointed out in the comments) is to enable automatic resource management. If you enable automatic resource management, the client will essentially call goOffline() when the app goes into the background and goOnline() when it comes back to the foreground.

  5. android - Firebase Crashlytics Console not showing crashes on neither new or old builds anymore
  6. Question:

    i am having an issue with firebase Crashlytics where crashes are not showing up but the crash free rate percentage is.

    The Problem

    One day, on what seemed like a random day, all Crashlytic logs stopped showing up on the Firebase Crashlytics console. The crash free rate percentage, however, does show up there. I assume that they are indeed getting some data, because in order to calculate this crash free percentage they need the crash log data (maybe not, idk).

    To add to this, older builds where crashes used to be seen, also stopped showing the crash logs in the Firebase Crashlytics console. At this point i am convinced that it might not be a configuration issue on our end, if it was older builds shouldnt be affected.

    There are no error logs either, telling us that something is wrong.

    What i have tried

    • Checked to see if we changed anything related to firebase crashlytics (besides updating to the latest version)
    • Updating to the latest firebase Crashlytics version (multiple times)
    • Ive tried comparing the google-services.json file to the one we have in the project, and it is the same.
    • Contacting the firebase team, been at it for a few weeks now and still could not resolve, ive sent the logs, code snippets, everything they asked for. But still no solution.
    • Made sure we no longer have any references to the old crashlytics/fabric plugin/implementation.

    Project info:

      - Kotlin version: 1.4.10
      - Gradle plugin version: 4.0.2
      - firebase-crashlytics-gradle version: 2.3.0
      - Firebase Crashlytics version: 17.2.2
    

    Existing Crashlytics configuration:

    Project level build.gradle

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    buildscript {
    
        repositories {
            google()
            jcenter()
            maven { url 'https://plugins.gradle.org/m2/' }
        }
    
        dependencies {
            classpath 'com.android.tools.build:gradle:4.0.2'
            classpath "com.apollographql.apollo:apollo-gradle-plugin:1.2.0"
            classpath group: 'commons-io', name: 'commons-io', version: '2.5'
            classpath 'com.google.gms:google-services:4.3.4'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.10"
            classpath 'com.google.firebase:perf-plugin:1.3.2'
            classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
        }
    }
    
    allprojects {
        repositories {
            google()
            mavenCentral()
            jcenter()
            maven { url 'https://jitpack.io' }
        }
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    
    

    App level build.gradle

    import groovy.json.JsonOutput
    import org.apache.commons.io.IOUtils
    
    apply plugin: 'com.android.application'
    apply plugin: 'com.google.firebase.firebase-perf'
    apply plugin: 'com.google.firebase.crashlytics'
    apply plugin: 'kotlin-android'
    apply plugin: 'kotlin-kapt'
    apply plugin: 'kotlin-android-extensions'
    
    if (project.hasProperty("enableJacoco")) {
        apply from: '../jacoco.gradle'
    }
    
    repositories {
        maven { url 'https://www.jitpack.io' }
        flatDir {
            dirs 'libs'
        }
    }
    
    androidExtensions {
        experimental = true
    }
    
    android {
        compileSdkVersion 29
        buildToolsVersion "29.0.2"
        defaultConfig {
            applicationId "com.my-app"
            minSdkVersion 21
            targetSdkVersion 29
    
            testInstrumentationRunner "com.my-app.TestAppJUnitRunner"
    
            vectorDrawables.useSupportLibrary = true
    
            // for auto factory
            javaCompileOptions {
                annotationProcessorOptions {
                    includeCompileClasspath = true
                }
            }
        }
    
        buildTypes {
            release {
                minifyEnabled true
                zipAlignEnabled true
                debuggable false
                testCoverageEnabled false
    
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
            debug {
                FirebasePerformance {
                    instrumentationEnabled false
                }
                debuggable true
                testCoverageEnabled project.hasProperty("enableJacoco")
    
                firebaseCrashlytics {
                    mappingFileUploadEnabled false
                }
            }
        }
    
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
            // Flag to enable support for the new language APIs
            coreLibraryDesugaringEnabled true
        }
    
        useLibrary 'android.test.runner'
        useLibrary 'android.test.base'
        useLibrary 'android.test.mock'
    }
    
    dependencies {
    
        // Firebase
        implementation "com.google.firebase:firebase-messaging:20.1.0"
        implementation "com.google.firebase:firebase-core:17.2.0"
        implementation "com.google.firebase:firebase-perf:19.0.0"
        implementation "com.google.firebase:firebase-auth:19.2.0"
    
        implementation "com.google.firebase:firebase-analytics:17.6.0"
        implementation "com.google.firebase:firebase-crashlytics:17.2.2"
        
    }
    
    apply plugin: 'com.google.gms.google-services'
    

    (cleaned up to show firebase related only)


    Note: We have our google-services.json located in the proper location in our project, as it always been.

    Was hoping someone else would be able to help. Thanks in advance!


    Solution 1:

    In the new version of Firebase crashlytics (after migration from fabric) , reports of IPs of countries that are under the sanctions of Google are not visible in the console. This may be someone's problem.

  7. android - ProgressDialog does not want to update the message
  8. Question:

    I just tried to implement a progressdialog and I have some issues to change the text during my long and complex calculations.

    for (String aString:myStringArray){
        Log.v(TAG, aString);
        mProgressDialog.incrementProgressBy(1);
        mProgressDialog.setMessage(aString);
    }
    

    I can clearly see the incrementProgressBy working and my dialog updating, but the message does not change.

    Any idea on how to make that work?

    Thank a lot.


    Solution 1:

    Just found the answer, that's working fine:

    runOnUiThread(changeMessage);
    

    with that code:

    private Runnable changeMessage = new Runnable() {
        @Override
        public void run() {
            //Log.v(TAG, strCharacters);
            m_ProgressDialog.setMessage(strCharacters);
        }
    };
    

    Solution 2:

    I upload pictures to Firebase in a loop and updating the ProgressDialog each image:

    (I am in a Fragment, so I use getActivity() before calling to runOnUiThread())

    List<Bitmap> bitmaps;
    int picCounter = 1;
    ...
    
    progressDialog = ProgressDialog.show
     (getContext(), "sending...", "just a minute", false, false);
    
    new Thread(new Runnable() {
        @Override
        public void run() {
            for (int i = 0; i < bitmaps.size(); i++) {
    
                String filename = String.valueOf(i);
    
                uploadPic(bitmaps.get(i), "img" + filename, new MyCallback() {
                    @Override
                    public void onFinish() {
                        picCounter++;
                        Objects.requireNonNull(getActivity()).runOnUiThread(new Runnable() {
                            public void run() {
                                progressDialog.setTitle ("upoading " + picCounter + "image from " + bitmaps.size());
                            }
                        });
                    }
                });
            }
       }
    }).start();
    

    uploadPic method:

    public interface MyCallback { void onFinish ();}
    
    private void uploadPic(final Bitmap bitmap, final String fileName, final MyCallback callback) {
       ... // uploading to firebase and then:
       callback.onFinish();
    }
    

  9. android - Why are the custom events of Firebase analytics not shown on dashboard?
  10. Question:

    I have integrated firebase into my Android application. I am sending custom events as follows :

     Bundle bundle = new Bundle();
            bundle.putString("First Category", "First catValue");
            bundle.putString("sub Cat", "sub CatValue");
            bundle.putLong(FirebaseAnalytics.Param.VALUE, "value");
            firebaseAnalytics.logEvent("My Custom Event", bundle);
    

    None of my custom events show on events tab on firebase analytics dashboard.

    I have taken look in some questions already asked like this one : Android Firebase Analytics Custom Events Reporting in Console

    But couldn't solve my problem as I tried some of the suggestions there, like it was suggested to test with more than 10 users to be able to get the custom events which I did but nothing is shown in the events tab.

    I debugged using following commands:

    adb shell setprop log.tag.FA VERBOSE
    adb shell setprop log.tag.FA-SVC VERBOSE
    adb logcat -v time -s FA FA-SVC
    

    My events are getting logged on command prompt but not getting reflected on firebase dashboard.

    Am I sending custom events wrongly ? Do I need to configure anything on firebase dashboard to get the custom events ?

    Update :

    When I debugged using commands :

     adb shell setprop log.tag.FA VERBOSE
        adb shell setprop log.tag.FA-SVC VERBOSE
        adb logcat -v time -s FA FA-SVC
    

    I found this important log stating Name must consist of letters, digits or _ (underscores).

    Then I changed my event as below :

     Bundle bundle = new Bundle();
                bundle.putString("First_Category", "First_catValue");
                bundle.putString("sub_Cat", "sub_CatValue");
                bundle.putLong(FirebaseAnalytics.Param.VALUE, "value");
                firebaseAnalytics.logEvent("My_Custom_Event", bundle);
    

    Then I enabled debug view https://support.google.com/firebase/answer/7201382?hl=en&utm_id=ad as suggested by adbitx in answer below, then events started showing.


    Solution 1:

    Update :

    When I debugged using commands :

        adb shell setprop log.tag.FA VERBOSE
        adb shell setprop log.tag.FA-SVC VERBOSE
        adb logcat -v time -s FA FA-SVC
    

    I found this important log stating

    Name must consist of letters, digits or _ (underscores).
    

    Then I changed my event as below :

     Bundle bundle = new Bundle();
                bundle.putString("First_Category", "First_catValue");
                bundle.putString("sub_Cat", "sub_CatValue");
                bundle.putLong(FirebaseAnalytics.Param.VALUE, "value");
                firebaseAnalytics.logEvent("My_Custom_Event", bundle);
    

    Then I enabled debug view https://support.google.com/firebase/answer/7201382?hl=en&utm_id=ad as suggested by adbitx in answer, then events started showing.

    Solution 2:

    It usually takes a few hours for the data to show up on your dashboard. If you would like to check whether your events are logged and received correctly by Firebase Analytics, try DebugView and you should be able to verify the traffic. The 10 users threshold is for Audience, not custom events.