问题描述
我正在尝试在需要Gradle 1.10的最新版本的Andriod 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'
}
解决方法
当我尝试导入我正在上课的文件时,出现此错误。经过几天的挖掘和一些运气,了解了gradle版本和Android Gradle Plugin版本。这些数字不同,但是必须按照此链接中的表格进行对应:https://developer.android.com/studio/releases/gradle-plugin在获得该数字之后,我不得不进入build.gradle文件并将其更改为该文件。我的更改带有注释
codeRegistry.fieldsVisibility()
并在griddle-wrappers.properties文件中更改
// 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
}
到
distributionUrl=https://services.gradle.org/distributions/gradle-2.10-all.zip
如果您查看链接中的表格,您会发现该build.gradle文件行中的4.1.0
distributionUrl=https://services.gradle.org/distributions/gradle-6.5-all.zip
与此gradle-wrapper.properties行中的6.5全部匹配
classpath 'com.android.tools.build:gradle:4.1.0'
我没有尝试过,但我可以想象,只要图表上的数字彼此对应,即使它不是这些数字也可以使用。
希望这对您有所帮助。
,尝试将Android Gradle插件更新为最新的可用版本:
更改
classpath 'com.android.tools.build:gradle:1.5.0'
到
classpath 'com.android.tools.build:gradle:2.3.2'
,
是的-但是IDE似乎不知道最新版本。当出现此类错误时,我会使用最新版本,但IDE会创建一条无用的错误消息。我们知道房子着火了,ee想把它扑灭...