Gradle Project Sync失败Android Studio 3.0(JDK 9.0.1)

时间:2017-11-14 14:10:19

标签: java android android-studio gradle synchronization

我尝试了所有解决方案来修复它,但没有任何成功。 (将gradle转为“离线工作”,删除.gradle文件,无效并重新启动。我还完全删除了jdk-android studio并重新安装。)

这是问题的截图: Android Studio 3.0 Gradle Sync问题 enter image description here

这是我的java版本 enter image description here

here是系统/日志文件:

5 个答案:

答案 0 :(得分:0)

我认为添加构建工具和sdk版本23或24 如果您选择使用23个构建工具和sdk版本,请添加像这样的依赖

编译'com.android.support:appcompat-v7:23.1.1'

注意: 只要你选择了23个构建工具和sdk版本,无论它在哪里写入26,用23替换 如果还有任何问题,你可以问。

答案 1 :(得分:0)

你可以在Android studio中打开build.gradle文件,然后像这样更改compileSdkVersion,buildToolsVersion依赖

android {
compileSdkVersion 23
buildToolsVersion "24.0.1"
....
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'

}

如果您不理解,可以分享build.gradle文件的屏幕截图吗? 这是在Android工作室的左侧,在Gradle Scripts下 - > build.gradle(Modual:app)

答案 2 :(得分:0)

这样做

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
defaultConfig {
    applicationId "com.example.hackl.happybirthday"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner 
   "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:23.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'}

并立即点击同步(当您在此文件中进行更改时,它会自动显示)

答案 3 :(得分:0)

Take these easy steps as per developer.android.com
first add these lines on build.gradle file

buildscript {
    repositories {
            jcenter()
        // You need to add the following repository to download the
        // new plugin.
        google()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
    }
}


after that
update Gradle manually, edit the URL in gradle-wrapper.properties to the following:
distributionUrl=\
  https\://services.gradle.org/distributions/gradle-4.1-all.zip


For your reference you can check the below link 
https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html

答案 4 :(得分:0)

我完全卸载了Android Studio并重新安装了3次。在每个步骤中,我都单击了Gradle Sync错误消息并安装了所有丢失的文件。第3次安装成功,摆脱了正确安装丢失文件的gradle同步问题。我不知道如何以及为什么第一次和第二次安装都没有成功。无论如何,它已经完成了。

注意:在此之前我已经尝试了所有的答案。非常感谢。

Succeeded