【问题标题】:Gradle sync failed: Unsupported method: SyncIssue.getMultiLineMessage(). (Android Studio)Gradle 同步失败:不支持的方法:SyncIssue.getMultiLineMessage()。 (安卓工作室)
【发布时间】:2020-10-18 02:07:24
【问题描述】:

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

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

【问题讨论】:

    标签: java android android-studio gradle android-gradle-plugin


    【解决方案1】:

    当我尝试为我正在学习的课程导入文件时,一直收到此错误。挖了几天,有点运气,后来了解了gradle版本和Android Gradle Plug in版本。数字不一样,但它们必须按照此链接中的表格对应: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 后,这对我有用。我为你们所有人使用了类路径'com.android.tools.build:gradle:7.0.2'和distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip懒得去查链接了。
    【解决方案2】:

    尝试将 Android Gradle 插件更新到最新的可用版本:

    改变

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

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

    【讨论】:

    • 那条线在哪里?
    【解决方案3】:

    确实如此 - 但是 IDE 似乎不知道最新版本。当我收到此类错误时,我会使用最新版本,但 IDE 会创建一条无用的错误消息。我们知道房子着火了,我们想知道如何将其扑灭...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-08
      • 1970-01-01
      • 2014-04-30
      • 1970-01-01
      • 1970-01-01
      • 2013-05-11
      相关资源
      最近更新 更多