Android Studio 3.1:找不到 org.jetbrains.trove4j:trove4j:20160824

Android Studio 3.1 : Could not find org.jetbrains.trove4j:trove4j:20160824

昨天,我将 Android Studio 更新到 3.1,但出现此错误:

 Could not find org.jetbrains.trove4j:trove4j:20160824.
Searched in the following locations:
    https://repo.maven.apache.org/maven2/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
    https://repo.maven.apache.org/maven2/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.jar
    https://dl.google.com/dl/android/maven2/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
    https://dl.google.com/dl/android/maven2/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.jar
Required by:
    project :library > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1 > com.android.tools.lint:lint:26.0.1 > com.android.tools.lint:lint-checks:26.0.1 > com.android.tools.lint:lint-api:26.0.1 > com.android.tools.external.com-intellij:intellij-core:26.0.1

这是我项目的 gradle 文件:

    buildscript {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
//        classpath 'com.google.gms:google-services:1.5.0-beta2'
        classpath 'com.google.gms:google-services:3.1.1'

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

allprojects {
    repositories {
        jcenter()
        maven { url 'https://maven.fabric.io/public' }

        maven {
            url 'https://maven.google.com/'

        }
    }
}

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

这是我的 gradle-wrapper-properties 的 distdistributionUrl:

distdistributionUrl=https://services.gradle.org/distributions/gradle-4.4-all.zip

我犯了同样的错误……对我来说,以下方法有效:

  1. jcenter() 添加到 allprojectsrepositories {}
  2. 并在 build.gradle 应用程序模块中添加 compile 'org.jetbrains.trove4j: trove4j: 20160824'

尝试将 gradle 构建中所有出现的 maven Central() 替换为 jcenter()

我有同样的错误。我也在适当的地方有 jcentre() 。但它仍然没有用。 您可以做的对我有用的一件事是清除缓存:

1.关闭 Android Studio。

2。清除此处的缓存:

C:\Users"用户名"\.android\caches

C:\Users"用户名"\.gradle\caches

3。打开 Android Studio。

还要确保您的 gradle 版本高于最低要求。

因为jCenter will close in May, you should replace it with Maven. Thanks to giorgos.nl now we can add Trove4j:20160824. Thanks to Xavier Rubio Jansana我们可以用gradlePluginPortal()替换maven { url 'https://plugins.gradle.org/m2/' }

在根 build.gradle 中写入:

buildscript {
    repositories {
        google()
        gradlePluginPortal()
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        // org.jetbrains.trove4j:trove4j:20160824.
        gradlePluginPortal()
    }
}

要添加尚未移动到 mavenCentral 的库,请使用

build.gradle:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

那么您应该搜索 GitHub 个未解析库的存储库。带有两个库的应用 build.gradle 示例:

dependencies {
    // When a library has tags.
    implementation 'com.github.RedMadRobot:input-mask-android:6.0.0'
    // When a library doesn't have tags.
    implementation 'com.github.savvisingh:DateRangePicker:master'
}

现在我们可以启动应用程序并构建 apk 而不会出现错误。