java - Gradle Build Failed: NullPointerException in error_prone_annotations-2.36.0.jar during Dexing - Stack Overflow

admin2025-04-16  5

'm facing an issue while building my Android project with Gradle. The build fails with a NullPointerException related to error_prone_annotations-2.36.0.jar. Here’s the full error message:

ERROR: C:\Users\habib\.gradle\caches\transforms-3\e646cb792b71c76b98054fc8aca82c16\transformed\jetified-error_prone_annotations-2.36.0.jar: 

D8: java.lang.NullPointerException: Cannot invoke "String.length()" because "" is null

FAILURE: Build failed with an exception.

What went wrong: Execution failed for task ':app:mergeExtDexDebug'. Could not resolve all files for configuration ':app:debugRuntimeClasspath'.

Failed to transform error_prone_annotations-2.36.0.jar (com.google.errorprone:error_prone_annotations:2.36.0) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=21, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}. Execution failed for DexingWithClasspathTransform: C:\Users\habib.gradle\caches\transforms-3\e646cb792b71c76b98054fc8aca82c16\transformed\jetified-error_prone_annotations-2.36.0.jar. > Error while dexing.

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

BUILD FAILED in 1m 40s Error: Gradle task assembleDebug failed with exit code 1

'm facing an issue while building my Android project with Gradle. The build fails with a NullPointerException related to error_prone_annotations-2.36.0.jar. Here’s the full error message:

ERROR: C:\Users\habib\.gradle\caches\transforms-3\e646cb792b71c76b98054fc8aca82c16\transformed\jetified-error_prone_annotations-2.36.0.jar: 

D8: java.lang.NullPointerException: Cannot invoke "String.length()" because "" is null

FAILURE: Build failed with an exception.

What went wrong: Execution failed for task ':app:mergeExtDexDebug'. Could not resolve all files for configuration ':app:debugRuntimeClasspath'.

Failed to transform error_prone_annotations-2.36.0.jar (com.google.errorprone:error_prone_annotations:2.36.0) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=21, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}. Execution failed for DexingWithClasspathTransform: C:\Users\habib.gradle\caches\transforms-3\e646cb792b71c76b98054fc8aca82c16\transformed\jetified-error_prone_annotations-2.36.0.jar. > Error while dexing.

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

BUILD FAILED in 1m 40s Error: Gradle task assembleDebug failed with exit code 1

Share Improve this question asked Feb 3 at 7:40 Mohamed HeshamMohamed Hesham 537 bronze badges
Add a comment  | 

5 Answers 5

Reset to default 3

Add this code to ignore all errorprone.. add it in android/build.gradle inside allprojects

 configurations.all {
    exclude group: "com.google.errorprone", module: "error_prone_annotations"
}

Exclude error_prone_annotations in android/build.gradle

 subprojects { subproject ->
        if(project['name'] == 'c72-rfid-scanner'){    
            project.configurations { compile { } }
        }else{
            configurations.all {
            exclude group: "com.google.errorprone", module: "error_prone_annotations"
             }
        }
    }

I have found something that has worked for me on https://issuetracker.google.com/issues/342522142 in comment 8. That is an internal bug and you can solve by adding these lines at the top of your android/settings.gradle :

pluginManagement {
    buildscript {
        repositories {
            mavenCentral()
            maven {
                url = uri("https://storage.googleapis.com/r8-releases/raw")
            }
        }
        dependencies {
            classpath("com.android.tools:r8:8.1.44")
        }
    }
}

I hope it will helpful to you as it has been for me.

You are having issues for the 'com.google.errorprone' library during the dexing process. Maybe there are conflicts or issues for this package.

configurations.all {
exclude group: 'com.google.errorprone', module: 'error_prone_annotations'}

Add this into your build.gradle (app level), and it will exclude this package in the build process.

I faced an issue where my project, which was working fine before, suddenly stopped building successfully. To fix this, I added the following code inside the dependencies block in my build.gradle file :

dependencies {
    ///add this code here ...
    configurations.all {
    exclude group: 'com.google.errorprone', module: 'error_prone_annotations'
    }
    ///end...
}

转载请注明原文地址:http://anycun.com/QandA/1744775472a87454.html