androidadmobadscrashlytics

Unable to start activity ComponentInfo{com.mypackage/com.google.android.gms.ads.NotificationHandlerActivity}


Firebase crashlytics has indicated a crash occuring on android 11 (API 30) Nexus 5X with the following stack trace...

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mypackage/com.google.android.gms.ads.NotificationHandlerActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3449)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
       at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
       at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:223)
       at android.app.ActivityThread.main(ActivityThread.java:7656)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
       at com.google.android.gms.internal.ads.zzefa.zze(com.google.android.gms:play-services-ads@@22.6.0:2)
       at com.google.android.gms.ads.NotificationHandlerActivity.onCreate(com.google.android.gms:play-services-ads-lite@@22.6.0:4)
       at android.app.Activity.performCreate(Activity.java:7994)
       at android.app.Activity.performCreate(Activity.java:7978)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
       at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
       at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:223)
       at android.app.ActivityThread.main(ActivityThread.java:7656)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

I have tried to reproduce this issue, but I have not been successful. It seems to be an internal issue with google ads, but I am unsure if it is. I don't know where to look in my app for code that could have caused this crash, since the stacktrace doesn't refrence a single line of my own code. If it helps, here is my build.gradle that includes my dependencies

project level

buildscript {
    dependencies {
        classpath("com.google.gms:google-services:4.4.0")
    }
}

plugins {
    id("com.android.application") version "8.2.1" apply false
    id("com.android.library") version "8.2.1" apply false
    id("com.google.gms.google-services") version "4.4.0" apply false
    id("com.google.firebase.crashlytics") version "2.9.9" apply false
    id("com.google.firebase.firebase-perf") version "1.4.2" apply false
    kotlin("android") version "1.8.10" apply false
}

module level

plugins {
    id("com.android.application")
    id("org.jetbrains.kotlin.android")
    id("com.google.gms.google-services")
    id("com.google.firebase.crashlytics")
    id("com.google.firebase.firebase-perf")
}

android {
    namespace = "com.mypackage"
    compileSdk = 34

    defaultConfig {
        applicationId = "com.mypackage"
        minSdk = 29
        targetSdk = 34
        versionCode = 8
        versionName = "myversion"

        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        debug {
            isMinifyEnabled = false
            isDebuggable = true
            isShrinkResources = false
        }
        
        release {
            isMinifyEnabled = true
            isDebuggable = false
            isShrinkResources = true
            proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
            signingConfig = signingConfigs["debug"]
        }
    }

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = "1.8"
    }

    buildFeatures {
        viewBinding = true
        buildConfig = true
    }
}

dependencies {
    // Firebase Libraries
    implementation(platform("com.google.firebase:firebase-bom:32.7.0"))
    implementation("com.google.firebase:firebase-analytics")
    implementation("com.google.firebase:firebase-crashlytics")
    implementation("com.google.firebase:firebase-perf")
    implementation("com.google.firebase:firebase-inappmessaging-display")

    // Google Play Services
    implementation("com.google.android.gms:play-services-maps:18.2.0")
    implementation("com.google.android.gms:play-services-location:21.0.1")
    implementation("com.google.android.gms:play-services-ads:22.6.0")
    implementation("com.google.android.play:review-ktx:2.0.1")

    // Google Libraries
    implementation("com.google.guava:guava:32.1.3-jre")
    implementation("com.google.android.libraries.places:places:3.3.0")
    implementation("com.google.maps.android:android-maps-utils:3.8.0")
    implementation("com.android.billingclient:billing-ktx:6.1.0")
    implementation("com.google.android.material:material:1.11.0")

    // AndroidX Libraries
    implementation("androidx.concurrent:concurrent-futures-ktx:1.1.0")
    implementation("androidx.work:work-runtime:2.9.0")
    implementation("androidx.core:core-ktx:1.12.0")
    implementation("androidx.appcompat:appcompat:1.6.1")
    implementation("androidx.constraintlayout:constraintlayout:2.1.4")
    implementation("androidx.navigation:navigation-fragment-ktx:2.7.6")
    implementation("androidx.navigation:navigation-ui-ktx:2.7.6")
    implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
    implementation("androidx.fragment:fragment-ktx:1.6.2")

    // KotlinX Libraries
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")

    // Compose Libraries
    implementation("androidx.compose.material3:material3:1.1.2")
    implementation("com.google.android.material:compose-theme-adapter-3:1.1.1")

    // Other Libraries
    implementation("com.luckycatlabs:SunriseSunsetCalculator:1.2")
    implementation("com.github.mmin18:realtimeblurview:1.2.1")
    implementation("com.squareup.picasso:picasso:2.71828")
    implementation(project(":nativetemplates"))

    // Testing Libraries
    testImplementation("junit:junit:4.13.2")
    androidTestImplementation("androidx.test.ext:junit:1.1.5")
    androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
}


Solution

  • I have often received similar, or the same, stack traces for a Nexus 5X …

    Fatal Exception: java.lang.RuntimeException Unable to start activity ComponentInfo{com.xxxx.xxxx/com.google.android.gms.ads.NotificationHandlerActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference

    .. soon after releasing a new version to the Google Play Store.

    After a bit of Googling these Nexus 5X crash reports appear to be related to Google Play Store testing, for example https://issuetracker.google.com/issues/268432128.

    I would just tend to ignore any reported crashes from a Nexus 5X. According to Wikipedia the Nexus 5X was discontinued in 2016 so these devices are unlikely to make up any significant percentage of the real app install base anyway.