任务“:app:mergeLibDexDebug”执行失败。 > 无法解析配置“:app:debugRuntimeClasspath”的所有文件

问题描述 投票:0回答:1

当我在 flutter run 中运行代码时,会发生错误。最近我更改了 gradle 属性文件。 7版本到8版本。

ERROR:/Users/mohamedrifay/Desktop/Projects/fitish-flutter/build/firebase_auth/intermediates/runtime_library_classes_jar/debug/classes.jar: D8: java.lang.NullPointerException: Cannot invoke "String.length()" because "<parameter1>" is null
ERROR:/Users/mohamedrifay/Desktop/Projects/fitish-flutter/build/firebase_core/intermediates/runtime_library_classes_jar/debug/classes.jar: D8: java.lang.NullPointerException: Cannot invoke "String.length()" because "<parameter1>" is null
ERROR:/Users/mohamedrifay/Desktop/Projects/fitish-flutter/build/flutter_local_notifications/intermediates/runtime_library_classes_jar/debug/classes.jar: D8: java.lang.NullPointerException: Cannot invoke "String.length()" because "<parameter1>" is null
ERROR:/Users/mohamedrifay/Desktop/Projects/fitish-flutter/build/url_launcher_android/intermediates/runtime_library_classes_jar/debug/classes.jar: D8: java.lang.NullPointerException: Cannot invoke "String.length()" because "<parameter1>" is null
ERROR:/Users/mohamedrifay/Desktop/Projects/fitish-flutter/build/path_provider_android/intermediates/runtime_library_classes_jar/debug/classes.jar: D8: java.lang.NullPointerException: Cannot invoke "String.length()" because "<parameter1>" is null
ERROR:/Users/mohamedrifay/Desktop/Projects/fitish-flutter/build/google_sign_in_android/intermediates/runtime_library_classes_jar/debug/classes.jar: D8: java.lang.NullPointerException: Cannot invoke "String.length()" because "<parameter1>" is null
ERROR:/Users/mohamedrifay/Desktop/Projects/fitish-flutter/build/connectivity_plus/intermediates/runtime_library_classes_jar/debug/classes.jar: D8: java.lang.NullPointerException: Cannot invoke "String.length()" because "<parameter1>" is null

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeLibDexDebug'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Failed to transform classes.jar (project :firebase_auth) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, com.android.build.api.attributes.AgpVersionAttr=7.3.0, com.android.build.api.attributes.BuildTypeAttr=debug, com.android.build.gradle.internal.attributes.VariantAttr=debug, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=21, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
      > Execution failed for DexingWithClasspathTransform: /Users/mohamedrifay/Desktop/Projects/fitish-flutter/build/firebase_auth/intermediates/runtime_library_classes_jar/debug/classes.jar.
         > Error while dexing.
   > Failed to transform classes.jar (project :firebase_core) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, com.android.build.api.attributes.AgpVersionAttr=7.3.0, com.android.build.api.attributes.BuildTypeAttr=debug, com.android.build.gradle.internal.attributes.VariantAttr=debug, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=21, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
      > Execution failed for DexingWithClasspathTransform: /Users/mohamedrifay/Desktop/Projects/fitish-flutter/build/firebase_core/intermediates/runtime_library_classes_jar/debug/classes.jar.
         > Error while dexing.
   > Failed to transform classes.jar (project :flutter_local_notifications) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, com.android.build.api.attributes.AgpVersionAttr=7.3.0, com.android.build.api.attributes.BuildTypeAttr=debug, com.android.build.gradle.internal.attributes.VariantAttr=debug, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=21, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
      > Execution failed for DexingWithClasspathTransform: /Users/mohamedrifay/Desktop/Projects/fitish-flutter/build/flutter_local_notifications/intermediates/runtime_library_classes_jar/debug/classes.jar.
         > Error while dexing.
   > Failed to transform classes.jar (project :url_launcher_android) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, com.android.build.api.attributes.AgpVersionAttr=7.3.0, com.android.build.api.attributes.BuildTypeAttr=debug, com.android.build.gradle.internal.attributes.VariantAttr=debug, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=21, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
      > Execution failed for DexingWithClasspathTransform: /Users/mohamedrifay/Desktop/Projects/fitish-flutter/build/url_launcher_android/intermediates/runtime_library_classes_jar/debug/classes.jar.
         > Error while dexing.
   > Failed to transform classes.jar (project :path_provider_android) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, com.android.build.api.attributes.AgpVersionAttr=7.3.0, com.android.build.api.attributes.BuildTypeAttr=debug, com.android.build.gradle.internal.attributes.VariantAttr=debug, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=21, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
      > Execution failed for DexingWithClasspathTransform: /Users/mohamedrifay/Desktop/Projects/fitish-flutter/build/path_provider_android/intermediates/runtime_library_classes_jar/debug/classes.jar.
         > Error while dexing.
   > Failed to transform classes.jar (project :google_sign_in_android) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, com.android.build.api.attributes.AgpVersionAttr=7.3.0, com.android.build.api.attributes.BuildTypeAttr=debug, com.android.build.gradle.internal.attributes.VariantAttr=debug, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=21, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
      > Execution failed for DexingWithClasspathTransform: /Users/mohamedrifay/Desktop/Projects/fitish-flutter/build/google_sign_in_android/intermediates/runtime_library_classes_jar/debug/classes.jar.
         > Error while dexing.
   > Failed to transform classes.jar (project :connectivity_plus) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, com.android.build.api.attributes.AgpVersionAttr=7.3.0, com.android.build.api.attributes.BuildTypeAttr=debug, com.android.build.gradle.internal.attributes.VariantAttr=debug, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=21, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
      > Execution failed for DexingWithClasspathTransform: /Users/mohamedrifay/Desktop/Projects/fitish-flutter/build/connectivity_plus/intermediates/runtime_library_classes_jar/debug/classes.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.

应用程序/gradle

plugins {
    id "com.android.application"
    id "kotlin-android"
    id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

android {
    namespace "com.example.fitish_app"
    compileSdk 34
    ndkVersion flutter.ndkVersion

    //for notification
    defaultConfig {
        multiDexEnabled true
    }

    lintOptions {
            checkReleaseBuilds false
        }

    compileOptions {

         //for notification
        coreLibraryDesugaringEnabled true

        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.fitish_app"
        multiDexEnabled true
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdkVersion 21
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {

    implementation 'com.android.support:multidex:2.0.1'
    //for notification
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.2'

}

gradle.属性

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip

如何解决这个问题。

尝试在 flutter 中修复此问题。此应用程序在 ios 中成功运行,错误仅发生在 android 中。

什么错误。为什么会发生

android flutter macos gradle build.gradle
1个回答
0
投票

此依赖项中的问题

实现“androidx.core:core-ktx:+”

只需添加最新的 kotlin 版本而不是“+”并同步,同步后即可 重建gradle问题就解决了。

解决方案: 从 实现“androidx.core:core-ktx:+” 到: 实现“androidx.core:core-ktx:1.13.1”更新依赖关系。

© www.soinside.com 2019 - 2024. All rights reserved.