Gradle同步失败:不支持的方法:SyncIssue.getMultiLineMessage()。(Android Studio)

19

我正在尝试在最新版本的Android Studio上构建这个旧应用程序,需要使用Gradle 1.10。我一直收到同步错误(见下文)。

SYNC ERROR:
Gradle sync failed: Unsupported method: SyncIssue.getMultiLineMessage().
The version of Gradle you connect to does not support that method.
To resolve the problem you can change/upgrade the target version of Gradle you connect to.
Alternatively, you can ignore this exception and read other information from the model.
Consult IDE log for more details (Help | Show Log) (8 s 599 ms)

我应该在用 *** 标记的行中使用哪些版本/编号?

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
 ****       classpath 'com.android.tools.build:gradle:1.5.0'
    }
}
apply plugin: 'android'

repositories {
    mavenLocal()
    mavenCentral()
}
android {
***   compileSdkVersion 19
***   buildToolsVersion "19.1"

    defaultConfig {
 ***       minSdkVersion 10
 ***       targetSdkVersion 19
    }

    lintOptions {
        abortOnError false
    }
}
    
dependencies {
***   compile 'com.android.support:appcompat-v7:19.1.0'
***   compile 'com.bitalino:bitalino-java-sdk:1.0'
***   compile 'org.roboguice:roboguice:3.0b-experimental'
***   compile 'com.squareup.retrofit:retrofit:1.5.0'
}
3个回答

32

在我尝试导入一门课程的文件时,不断出现这个错误。几天的挖掘和一点运气后,我了解了gradle版本和Android Gradle插件版本。虽然数字不同,但它们必须与此链接中的表格相对应:https://developer.android.com/studio/releases/gradle-plugin 然后我必须进入build.gradle文件并将其更改为以下内容。我的更改已经注释。

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

buildscript {
    repositories {
        google()//Add this
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'//change to this

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

allprojects {
    repositories {
        google()//add this
        jcenter()
    }
}

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

在griddle-wrappers.properties文件中更改

distributionUrl=https://services.gradle.org/distributions/gradle-2.10-all.zip
distributionUrl=https://services.gradle.org/distributions/gradle-6.5-all.zip
如果您查看链接中的表格,您将会看到此 build.gradle 文件行中的 4.1.0 版本号。
classpath 'com.android.tools.build:gradle:4.1.0'

匹配 gradle-wrapper.properties 行中的 6.5-all

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

我没有尝试过,但我认为只要图表上的数字相对应,即使不是完全相同的数字,它也可以工作。

希望这可以帮助你。


在我更新了Android Studio之后,这个方法对我起作用了。我使用了“classpath 'com.android.tools.build:gradle:7.0.2'”和“distributionUrl=https://services.gradle.org/distributions/gradle-7.0.2-all.zip”,以防有些人懒得检查链接。 - David Read

0

确实是这样 - 但是IDE似乎不知道最新版本。当我遇到这种错误时,我会选择最新版本,但IDE创建的错误消息并不有用。我们知道房子着火了,我们想知道如何扑灭它...


0
尝试将Android Gradle插件更新到最新可用版本:
更改
classpath 'com.android.tools.build:gradle:1.5.0'

classpath 'com.android.tools.build:gradle:2.3.2'

那行在哪里? - jim

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接