user14800266
user14800266

Reputation:

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'
}

Upvotes: 4

Views: 9688

Answers (5)

ShamStack
ShamStack

Reputation: 1

  1. Create a new project
  2. Open "project file" view
  3. Open the gradle folder (Note: gradle not .gradle )
  4. Open wrapper folder
  5. Open gradle-wrapper.properties file
  6. Copy the entire distributionUrl line in this file

Repeat steps 2 to 5 on the project with the error

  1. Replace the distributionUrl line in the error containing project with the one copied from the new project
  2. Sync the project

Edit: Make sure you're connected to the internet when creating the new project.

Upvotes: 0

Abanoub Hany
Abanoub Hany

Reputation: 656

  1. Navigate to the Graddle Directory:

Go to the Graddle directory located at C:/Users/Your Username/.

  1. Rename the .gradle Folder:

Rename the .gradle folder to .gradle2. If you encounter difficulties renaming it due to it being in use by another program, restart your PC and then proceed with renaming the folder before opening Android Studio.

  1. Reopen Android Studio:

After renaming the folder, reopen Android Studio.

  1. Invalidate Cache and Restart:

    If necessary, invalidate the cache and restart Android Studio by following these steps:

Go to File > Invalidate Caches.

Upvotes: 0

Segrei Ulanov
Segrei Ulanov

Reputation: 171

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

Upvotes: 1

Edimilson Borges
Edimilson Borges

Reputation: 1

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

Upvotes: 0

user13146129
user13146129

Reputation:

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

Upvotes: 1

Related Questions