简体   繁体   中英

Caused by: java.lang.NoClassDefFoundError: org/gradle/internal/impldep/com/google/common/collect/Lists

When I am creating a new project in Android Studio, and load old projects I got this java.lang.NoClassDefFoundError: org/gradle/internal/impldep/com/google/common/collect/Lists java.lang.ClassNotFoundException: org.gradle.internal.impldep.com.google.common.collect.Lists ERROR: Unable to load class 'org.gradle.internal.impldep.com.google.common.collect.Lists'.

this is my gradle

plugins {
    id 'com.android.application'
    id 'kotlin-android'
}

android {
    compileSdkVersion 29
    buildToolsVersion "30.0.0"

    defaultConfig {
        applicationId "com.ncf.fitness"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}

dependencies {

    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.2.0'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'com.google.android.material:material:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

You didn't add kotlin version. Try adding kotlin version instead of $kotlin_version .

testImplementation 'junit:junit:4.+'

It also looks like it hasn't complete version name .

Then sync

I had the same problem, I solved it like this.

First go to the Module build.gradle file, in dependencies change gradle version to 3.2.1

dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
}

Then go to the gradle-wrapper.properties file, change gradle version back to gradle-5.4.1-all.zip

distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

Sync and you're done, problem solved.

I also had to change the versions of the dependencies in the build.gradle of the Project to

implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'

The end...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM