3

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'
}
desertnaut
  • 57,590
  • 26
  • 140
  • 166
  • Does this answer your question? [No Class Found: com.google.common.collect.Lists](https://stackoverflow.com/questions/38007629/no-class-found-com-google-common-collect-lists) – Priyanka Jan 19 '21 at 04:30

3 Answers3

1
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

1

This helped me when I downgraded the gradle plugin. Before the version as on the screen enter image description here

Segrei Ulanov
  • 141
  • 1
  • 4
0

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...