Android Studio无法同步和构建新的和旧的Kotlin项目

时间:2020-04-14 13:10:47

标签: android-studio kotlin gradle

当我在Android Studio中创建新项目并加载旧项目时,我得到了以下提示:

java.lang.NoClassDefFoundError:org / gradle / internal / impldep / com / google / common / collect / Lists java.lang.ClassNotFoundException:org.gradle.internal.impldep.com.google.common.collect.Lists 错误:无法加载类“ org.gradle.internal.impldep.com.google.common.collect.Lists”。 此意外错误的可能原因包括: Gradle的依赖项缓存可能已损坏(有时会在网络连接超时后发生。) 重新下载依赖项并同步项目(需要网络)

Gradle构建过程(守护程序)的状态可能已损坏

现在我完全被困住了。

1,    I downloaded studio again and installed to an other drive, the probleme still exists.  
2,    I deleted all of my Android Studios from my computer, I downloaded and installed again. Started a new kotlin  project, the same error happened.  
3,    invalidate/restart not fixed 
4,    redownload dependencies not fixed
5,    update gradle not fixed
6,    flutter plugin disabled, not fixed

我也将旧的Android Studio用于拍打/飞镖和Kotlin。看来我无法再构建本机应用程序/ kotlin。

我的gradle包装器

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

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.3.61'
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

构建gradle

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"

    defaultConfig {
        applicationId "hu.lacas.myapplication"
        minSdkVersion 19
        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'
        }
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

应用构建版本

有什么办法解决这个问题?

谢谢

1 个答案:

答案 0 :(得分:0)

大声笑。我发现一个旧项目是什么建造的!!! 我从中复制了以下字符串:

dependencies {
    classpath 'com.android.tools.build:gradle:3.2.0'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.71"
}

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

并最终同步,构建!!!

新的Android Studio中的某些问题非常严重,因为即使创建了新项目,我也会遇到很多错误/同步失败