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

huangapple go评论88阅读模式
英文:

Gradle sync failed: Unsupported method: SyncIssue.getMultiLineMessage(). (Android Studio)

问题

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

同步错误:
Gradle同步失败:不支持的方法:SyncIssue.getMultiLineMessage()
您连接的Gradle版本不支持该方法
要解决问题,您可以更改/升级您连接的Gradle的目标版本。
或者,您可以忽略此异常并从模型中读取其他信息。
有关更多详情,请参阅IDE日志(帮助|显示日志)(8秒599毫秒)

在下面标有***的行中,我应该有哪些版本/数字。

```Groovy
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'
}
英文:

I'm trying to build this old app on the newest version of Android Studio that requires Gradle 1.10. I keep getting sync errors (See below).

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)

What versions/numbers should I have in my lines that are marked with ***.

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

答案1

得分: 32

在尝试为我正在学习的课程导入文件时,我一直遇到这个错误。经过几天的挖掘和一点运气,我后来了解到了Gradle版本和Android Gradle插件版本的问题。尽管版本号不同,但它们必须与此链接中的表格相对应:https://developer.android.com/studio/releases/gradle-plugin 在我理解了这一点之后,我不得不进入build.gradle文件并将其更改为以下内容。我的更改如下:

// 顶层构建文件,在这里您可以添加所有子项目/模块共有的配置选项。

buildscript {
    repositories {
        google()//添加此行
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'//更改为这个版本

        // 注意:不要将应用程序依赖项放在这里;它们应属于各个模块的build.gradle文件中
    }
}

allprojects {
    repositories {
        google()//添加此行
        jcenter()
    }
}

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

还要在griddle-wrappers.properties文件中将以下行更改为:

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

我没有尝试过,但我想象只要数字在表格上相互对应,即使不是完全相同的数字,也应该可以工作。

希望这对您有所帮助。

英文:

Kept getting this error when I tried to import a file for a class I'm taking. Several days of digging and a little luck later, learned about gradle versions and Android Gradle Plug in versions. The numbers are not the same but they must correspond as per the table in this link: https://developer.android.com/studio/releases/gradle-plugin After I got that then I had to go into the build.gradle file and change it to this. My changes are annotated

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

and in the griddle-wrappers.properties file change

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

to

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

If you look at the table in the link you will see that the 4.1.0 in this build.gradle file line

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

matches the 6.5-all in this gradle-wrapper.properties line

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

I didn't try it but I would imagine that as long as the numbers correspond to each other on the chart then it would work even if it weren't exactly these numbers.

Hope this helps you out.

答案2

得分: 0

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

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

改为

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

Try updating the Android Gradle plugin to the latest available version:

Change

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

to

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

答案3

得分: 0

是的,确实 - 但是IDE似乎不知道最新版本。当我遇到这种类型的错误时,我会使用最新版本,但IDE生成了一条没有用的错误消息。我们知道房子着火了,我们想知道如何扑灭它...

英文:

Yes indeed - however the IDE does not seem to know the latest version. I go with the latest versions when I get this type of error but IDE creates an error message that is not useful. We know the house is on fire and ee want to how to put it out...

huangapple
  • 本文由 发表于 2020年10月18日 10:07:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/64409047.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定