简体   繁体   English

Gradle Project Sync Failed Android Studio 3.0(JDK 9.0.1)

[英]Gradle Project Sync Failed Android Studio 3.0 (JDK 9.0.1)

I tried all solutions to fix it, but nothing has succeeded. 我尝试了所有解决方案来修复它,但没有成功。 (Turned gradle to "offline work", deleted .gradle files, invalidated and restarted. I also removed the jdk-android studio completely and installed again.) (将gradle设置为“离线工作”,删除了.gradle文件,使其无效并重新启动。我还完全删除了jdk-android studio并再次安装。)

Here is the problem's screenshot: Android Studio 3.0 Gradle Sync Problem 这是问题的屏幕截图:Android Studio 3.0 Gradle Sync问题 在此处输入图片说明

Here is my java version 这是我的java版本 在此处输入图片说明

and here is the system/log file: 是系统/日志文件:

I think add build tools and sdk version 23 or 24 and if you select to use 23 build tools and sdk version, add dependency like this 我认为添加构建工具和SDK版本23或24,如果您选择使用23构建工具和SDK版本,请添加如下所示的依赖项

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

Note: Wherever its written 26, replace with 23, only if you choose to 23 build tools and sdk version If there is still any problem you can ask. 注意:无论它写在什么位置26,只要选择23构建工具和sdk版本,就用23代替。如果仍然有任何问题可以问。

You can open build.gradle file in Android studio, then change compileSdkVersion , buildToolsVersion dependencies like this 您可以在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'

} }

If you did not understood it, can you please share screen shots of your build.gradle file ? 如果您不了解,可以分享build.gradle文件的屏幕截图吗? Which is in left side of android studio, under Gradle Scripts -> build.gradle (Modual:app) 在android studio的左侧,在Gradle脚本-> build.gradle(Modual:app)下

Do it this way 这样做

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

and click sync now (it will be automatically appear when you make changes in this file) 并单击立即同步(在此文件中进行更改时,它将自动显示)

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

I uninstalled Android Studio completely and reinstall 3 times. 我完全卸载了Android Studio,然后重新安装了3次。 In every step I clicked on Gradle Sync error messages and installed all missing files. 在每一步中,我单击Gradle Sync错误消息并安装所有丢失的文件。 3rd time installation has succeeded with get rid of gradle sync problem with installing missing files correctly. 第三次安装成功,摆脱了gradle sync问题,正确安装了丢失的文件。 I don't know how and why it has not been successful 1st and 2nd time installation. 我不知道如何以及为什么第一次和第二次安装都没有成功。 Anyway, it's done. 无论如何,它已经完成。

Note: Before that I have tried all of answers. 注意:在此之前,我已经尝试了所有答案。 Thanks a lot. 非常感谢。

Succeeded 成功

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM