1

I am getting the below error when trying to build a release app bundle.

java.lang.NullPointerException: Cannot invoke "com.android.tools.r8.graph.i0.a(com.android.tools.r8.graph.y)" because the return value of "com.android.tools.r8.graph.j1.U0()" is null

build.gradle.kts (Project Level)

buildscript {

    repositories {
        google()
        mavenCentral()
        jcenter()
    }
}

plugins {
    alias(libs.plugins.android.application) apply false
    alias(libs.plugins.compose.compiler) apply false
    alias(libs.plugins.firebase.crashlytics) apply false
    alias(libs.plugins.firebase.performance.monitoring) apply false
    alias(libs.plugins.google.services) apply false
    alias(libs.plugins.hilt) apply false
    alias(libs.plugins.kotlin.android) apply false
    alias(libs.plugins.ksp) apply false
    alias(libs.plugins.navigation.safe.args) apply false
    alias(libs.plugins.oss.licenses) apply false
}

subprojects {
    tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
        kotlinOptions.jvmTarget = "1.8"
    }
}

tasks.register("clean",Delete::class){
    delete(rootProject.buildDir)
}

build.gradle.kts (App Level)

plugins {
    id("com.android.application")
    id("org.jetbrains.kotlin.plugin.compose")
    id("kotlin-android")
    id("kotlin-kapt")
    id("kotlin-parcelize")
    id("com.google.devtools.ksp")
    id("com.google.gms.google-services")
    id("com.google.android.gms.oss-licenses-plugin")
    id("dagger.hilt.android.plugin")
    id("androidx.navigation.safeargs.kotlin")
    id("com.google.firebase.crashlytics")
}

android {
    namespace = "myapp.abcx"
    compileSdk = 34

    androidResources {
        generateLocaleConfig = true // Per app language preference
    }

    bundle {
        language {
            enableSplit = false // Don't remove language resources in AAB
        }
    }

    defaultConfig {
        applicationId = "myapp.abcx"
        minSdk = 24
        targetSdk = 34
        versionCode = 58
        versionName = "2.58"
        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

        javaCompileOptions {
            annotationProcessorOptions {
                argument("room.schemaLocation", "$projectDir/schemas\".toString()")
            }
        }
    }

    kapt {
        correctErrorTypes = true
    }

    buildFeatures {
        viewBinding = true
        compose = true
    }

    buildTypes {
        debug {
            manifestPlaceholders["crashlyticsCollectionEnabled"] = "false"
        }

        release {
            isMinifyEnabled = true
            isShrinkResources = true

            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
            )
            manifestPlaceholders["crashlyticsCollectionEnabled"] = "true"
        }
    }

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

    kotlinOptions {
        jvmTarget = "1.8"
    }

}

dependencies {
    // AndroidX
    implementation(libs.androidx.activity.compose)
    implementation(libs.androidx.activity.ktx)
    implementation(libs.androidx.appcompat)
    implementation(libs.androidx.constraint.layout)
    implementation(libs.androidx.core.ktx)
    implementation(libs.androidx.core.splash.screen)

    // Browser
    implementation(libs.browser)

    // Coil
    implementation(libs.coil)
    implementation(libs.coil.compose)

    // Compose
    implementation(platform(libs.compose.bom))
    implementation(libs.compose.material3)
    implementation(libs.compose.material3.windowSizeClass)
    implementation(libs.compose.foundation)
    implementation(libs.compose.foundation.layout)
    implementation(libs.compose.ui)
    implementation(libs.compose.ui.text.google.fonts)
    implementation(libs.compose.ui.tooling)
    implementation(libs.compose.ui.tooling.preview)
    implementation(libs.compose.material.icons.extended)
    implementation(libs.compose.runtime)
    implementation(libs.compose.runtime.livedata)
    implementation(libs.compose.animation)

    // Dagger Hilt
    implementation(libs.dagger.hilt.android)
    kapt(libs.dagger.hilt.compiler)

    // Fast Adapter
    implementation(libs.fast.adapter)
    implementation(libs.fast.adapter.extensions.binding)
    implementation(libs.fast.adapter.extensions.diff)
    implementation(libs.fast.adapter.extensions.utils)

    // Firebase
    implementation(platform(libs.firebase.bom))
    implementation(libs.firebase.analytics.ktx)
    implementation(libs.firebase.crashlytics)
    implementation(libs.firebase.config.ktx)
    implementation(libs.firebase.dynamic.links.ktx)
    implementation(libs.firebase.messaging.ktx)
    implementation(libs.firebase.inappmessaging.ktx)
    implementation(libs.firebase.inappmessaging.display.ktx)
    implementation(libs.firebase.performance.monitoring)

    // Google Ads & UMP SDK
    implementation(libs.google.ads)
    implementation(libs.google.ads.ump.sdk)

    // Google
    implementation(libs.google.android.material)
    implementation(libs.google.android.material.compose.theme.adapter)

    // Kotlin
    implementation(libs.kotlin.stdlib)

    // Kotpref
    implementation(libs.kotpref)

    // Lifecycle
    implementation(libs.lifecycle.extensions)
    implementation(libs.lifecycle.viewmodel.ktx)
    implementation(libs.lifecycle.livedata.ktx)
    implementation(libs.lifecycle.runtime.ktx)
    implementation(libs.androidx.lifecycle.runtimeCompose)
    implementation(libs.androidx.lifecycle.viewModelCompose)

    // Lottie
    implementation(libs.lottie)

    // Navigation
    implementation(libs.navigation.fragment)
    implementation(libs.navigation.ui)

    // OSS Licenses
    implementation(libs.oss.licenses)

    // Play Core InApp Review
    implementation(libs.play.core.inapp.review)

    // Room
    implementation(libs.room.ktx)
    implementation(libs.room.runtime)
    ksp(libs.room.compiler)

    // Slide Button
    implementation(libs.slide.button)

    // Timber
    implementation(libs.timber)

    // TimeAgo
    implementation(libs.time.ago)
}

libs.versions.toml

[versions]

androidGradlePlugin = "8.5.0"
androidxActivity = "1.9.0"
androidxAppCompat = "1.7.0"
androidxConstraintLayout = "2.1.4"
androidxCoreKtx = "1.13.1"
androidxCoreSplashScreen = "1.0.1"
browser = "1.8.0"
coil = "2.6.0"
coilCompose = "2.6.0"
composeBom = "2024.06.00"
daggerHilt = "2.50"
fastAdapter = "5.7.0"
firebaseBom = "33.1.1"
firebaseCrashlyticsPlugin = "3.0.2"
firebasePerformanceMonitoringPlugin = "1.4.2"
googleAds = "23.2.0"
googleAdsUmpSdk = "2.2.0"
googleAndroidMaterial = "1.12.0"
googleAndroidMaterialComposeThemeAdapter = "1.2.1"
googleServicesPlugin = "4.4.2"
kotlin = "2.0.0"
kotpref = "2.13.2"
kspPlugin = "2.0.0-1.0.22"
lifecycle = "2.8.3"
lifecycleExtensions = "2.2.0"
lottie = "6.4.0"
navigationFragment = "2.7.7"
navigationUi = "2.7.7"
navigationSafeArgsPlugin = "2.7.7"
ossLicenses = "17.1.0"
ossLicensesPlugin = "0.10.6"
playCoreInAppReview = "2.0.1"
room = "2.6.1"
slideButton = "0.9.0"
timber = "5.0.1"
timeAgo = "4.0.3"


[libraries]

androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "androidxActivity" }
androidx-activity-ktx = { group = "androidx.activity", name = "activity-ktx", version.ref = "androidxActivity" }
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidxAppCompat" }
androidx-constraint-layout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "androidxConstraintLayout" }
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "androidxCoreKtx" }
androidx-core-splash-screen = { group = "androidx.core", name = "core-splashscreen", version.ref = "androidxCoreSplashScreen" }

browser = { group = "androidx.browser", name = "browser", version.ref = "browser" }

coil = { group = "io.coil-kt", name = "coil", version.ref = "coil" }
coil-compose = { group = "io.coil-kt", name = "coil-compose", version.ref = "coilCompose" }

compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
compose-material3 = { group = "androidx.compose.material3", name = "material3" }
compose-material3-windowSizeClass = { group = "androidx.compose.material3", name = "material3-window-size-class" }
compose-foundation = { group = "androidx.compose.foundation", name = "foundation" }
compose-foundation-layout = { group = "androidx.compose.foundation", name = "foundation-layout" }
compose-ui = { group = "androidx.compose.ui", name = "ui" }
compose-ui-text-google-fonts = { group = "androidx.compose.ui", name = "ui-text-google-fonts" }
compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
compose-material-icons-extended = { group = "androidx.compose.material", name = "material-icons-extended" }
compose-runtime = { group = "androidx.compose.runtime", name = "runtime" }
compose-runtime-livedata = { group = "androidx.compose.runtime", name = "runtime-livedata" }
compose-animation = { group = "androidx.compose.animation", name = "animation" }

dagger-hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref = "daggerHilt" }
dagger-hilt-compiler = { group = "com.google.dagger", name = "hilt-compiler", version.ref = "daggerHilt" }

fast-adapter = { group = "com.mikepenz", name = "fastadapter", version.ref = "fastAdapter" }
fast-adapter-extensions-binding = { group = "com.mikepenz", name = "fastadapter-extensions-binding", version.ref = "fastAdapter" }
fast-adapter-extensions-diff = { group = "com.mikepenz", name = "fastadapter-extensions-diff", version.ref = "fastAdapter" }
fast-adapter-extensions-utils = { group = "com.mikepenz", name = "fastadapter-extensions-utils", version.ref = "fastAdapter" }

firebase-bom = { group = "com.google.firebase", name = "firebase-bom", version.ref = "firebaseBom" }
firebase-analytics-ktx = { group = "com.google.firebase", name = "firebase-analytics-ktx" }
firebase-crashlytics = { group = "com.google.firebase", name = "firebase-crashlytics-ktx" }
firebase-config-ktx = { group = "com.google.firebase", name = "firebase-config-ktx" }
firebase-dynamic-links-ktx = { group = "com.google.firebase", name = "firebase-dynamic-links-ktx"}
firebase-messaging-ktx = { group = "com.google.firebase", name = "firebase-messaging-ktx"}
firebase-inappmessaging-ktx = { group = "com.google.firebase", name = "firebase-inappmessaging-ktx" }
firebase-inappmessaging-display-ktx = { group = "com.google.firebase", name = "firebase-inappmessaging-display-ktx" }
firebase-performance-monitoring = { group = "com.google.firebase", name = "firebase-perf-ktx"}

google-ads = { group = "com.google.android.gms", name = "play-services-ads", version.ref = "googleAds" }
google-ads-ump-sdk = { group = "com.google.android.ump", name = "user-messaging-platform", version.ref = "googleAdsUmpSdk" }

google-android-material = { group = "com.google.android.material", name = "material", version.ref = "googleAndroidMaterial" }
google-android-material-compose-theme-adapter = { group = "com.google.android.material", name = "compose-theme-adapter", version.ref = "googleAndroidMaterialComposeThemeAdapter" }

kotlin-stdlib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version.ref = "kotlin" }

kotpref = { group = "com.chibatching.kotpref", name = "kotpref", version.ref = "kotpref" }

lifecycle-extensions = { group = "androidx.lifecycle", name = "lifecycle-extensions", version.ref = "lifecycleExtensions" }
lifecycle-viewmodel-ktx = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-ktx", version.ref = "lifecycle" }
lifecycle-livedata-ktx = { group = "androidx.lifecycle", name = "lifecycle-livedata-ktx", version.ref = "lifecycle" }
lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycle" }
androidx-lifecycle-runtimeCompose = { group = "androidx.lifecycle", name = "lifecycle-runtime-compose", version.ref = "lifecycle" }
androidx-lifecycle-viewModelCompose = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-compose", version.ref = "lifecycle" }

lottie = { group = "com.airbnb.android", name = "lottie-compose", version.ref = "lottie"}

navigation-fragment = { group = "androidx.navigation", name = "navigation-fragment-ktx", version.ref = "navigationFragment" }
navigation-ui = { group = "androidx.navigation", name = "navigation-ui-ktx", version.ref = "navigationUi" }

oss-licenses = { group = "com.google.android.gms", name = "play-services-oss-licenses", version.ref = "ossLicenses" }

play-core-inapp-review = { group = "com.google.android.play", name = "review-ktx", version.ref = "playCoreInAppReview" }

room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "room" }
room-ktx = { group = "androidx.room", name = "room-ktx", version.ref = "room" }
room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "room" }

slide-button = { group = "com.ncorti", name = "slidetoact", version.ref = "slideButton" }

timber = { group = "com.jakewharton.timber", name = "timber", version.ref = "timber" }

time-ago = { group = "com.github.marlonlom", name = "timeago", version.ref = "timeAgo" }


[plugins]

android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin"}
firebase-crashlytics = { id = "com.google.firebase.crashlytics", version.ref = "firebaseCrashlyticsPlugin" }
firebase-performance-monitoring = { id = "com.google.firebase.firebase-perf", version.ref = "firebasePerformanceMonitoringPlugin"}
google-services = { id = "com.google.gms.google-services", version.ref = "googleServicesPlugin" }
hilt = { id = "com.google.dagger.hilt.android", version.ref = "daggerHilt" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
ksp = { id = "com.google.devtools.ksp", version.ref = "kspPlugin"}
navigation-safe-args = { id = "androidx.navigation.safeargs", version.ref = "navigationSafeArgsPlugin"}
oss-licenses = { id = "com.google.android.gms.oss-licenses-plugin", version.ref = "ossLicensesPlugin" }

I am unable to find any solution for this. Any help will be appreciated.

1 Answer 1

0

I've partially solved fixing the version of R8 lib com.android.tools:r8:8.3.37. The gradle plug in comes with a different one.

buildscript {

  dependencies {
     classpath libs.r8 // this goes first
     ...
  }
}

I don't think this should be the final solution but if you need for now might help.

Edit

I've created an issue on google issue tracker: https://issuetracker.google.com/issues/353475583

Not the answer you're looking for? Browse other questions tagged or ask your own question.