简体   繁体   English

Android Studio 3.1 Canary 3 - Gradle同步失败

[英]Android Studio 3.1 Canary 3 - Gradle sync failed

For a unknown reason Android Studio 3.1 Canary 3 is bugged and stopped to work, I updated gradle to 3.1-alpha03 and it stopped working, no matter if I download the project again, already downloaded Android Studio again too. 由于未知原因Android Studio 3.1 Canary 3被窃听并停止工作,我将gradle更新为3.1-alpha03并且它停止工作,无论我是否再次下载项目,已经再次下载了Android Studio。

I've already checkout old versions of the project, but this message still show: 我已经检查了该项目的旧版本,但此消息仍显示:

Gradle sync failed: com.android.tools.idea.gradle.project.model.AndroidModuleModel.getSelectedVariant()Lcom/android/tools/idea/gradle/project/model/ide/android/IdeVariant; (8s 806ms)

I've removed .idea folder, .gradle folder, did invalidate and restart 我删除了.idea文件夹, .gradle文件夹,确实无效并重新启动

I don't know nothing more to do, cant run or use the IDE. 我不知道还有什么可做的,无法运行或使用IDE。


Edit: 编辑:

图片


Edit2: EDIT2:

New Projects doesnt work too 新项目也不起作用

It's a problem with Kotlin 1.1.60-release-Studio3.0-1 plugin. 这是Kotlin 1.1.60-release-Studio3.0-1插件的问题。

Uninstall it from Android Studio and fetch an older version from here: https://plugins.jetbrains.com/plugin/6954-kotlin 从Android Studio卸载它并从此处获取旧版本: https//plugins.jetbrains.com/plugin/6954-kotlin

To solve this issue, you have to either upgrade or downgrade your kotlin plugin 要解决此问题,您必须升级或降级kotlin插件

Solution 1: Upgrade Plugin 解决方案1:升级插件

First go to Tools menu > Select Kotlin > Configure Kotlin Plugin Updates > Select one of the kotlin plugin & press download (stable or early access, i chose early access to solve this issue) 首先进入工具菜单>选择Kotlin>配置Kotlin插件更新>选择其中一个kotlin插件并按下载(稳定或早期访问,我选择提前访问以解决此问题)

And finally change the kotlin version in build.gradle(Project:) according to the downloaded version 最后根据下载的版本更改build.gradle(Project :)中的kotlin版本


在此输入图像描述

Solution 2: Downgrade Plugin 解决方案2:降级插件

If your on mac then press: Command + , to open preference, then select plugin & search for kotlin & uninstall it, it will rollback to previous version: 1.1.51 如果您在Mac上然后按: Command + ,打开首选项,然后选择插件并搜索kotlin并卸载它,它将回滚到以前的版本:1.1.51

On Windows machine , press Control + Alt + S to open settings dialog, then select plugins & search for kotlin & uninstall it, it will rollback to previous version: 1.1.51 Windows机器上 ,按Control + Alt + S打开设置对话框,然后选择插件并搜索kotlin并将其卸载,它将回滚到以前的版本:1.1.51

在此输入图像描述

Please Note: Do not uncheck kotlin in plugins else it will disable kotlin & fail to recognise kotlin file & syntax 请注意:不要在插件中取消选中kotlin,否则它将禁用kotlin并且无法识别kotlin文件和语法

尝试下载并安装这个用于android studio 3.1的kotlin插件

on Windows i just remove from C:\\Users\\ folder - 在Windows上我只是从C:\\ Users \\文件夹中删除 -

.AndroidStudioPreview3.1 .AndroidStudioPreview3.1

and all cache folders in .android ,.gradle too 以及.android,.gradle中的所有缓存文件夹

and problem is gone) 问题消失了)

Faced same problem after upgrading to Android Studio 3.1 stable . 升级到Android Studio 3.1稳定后面临同样的问题。

Kotlin plugin version was 1.2.30-release-Studio3.1-1 Kotlin插件版本是1.2.30-release-Studio3.1-1

So manually upgraded to, 所以手动升级到,

1.2.31-release-Studio3.1-1 1.2.31释放,Studio3.1-1

and boom, problem solved. 和繁荣,问题解决了。

In short, try upgrading to most relevant plugin to fix gradle sync failure. 简而言之,尝试升级到最相关的插件以修复gradle sync失败。

solved: 解决了:

first run -> find ~ -path ~/Library/Caches/Metadata/Safari -prune -o -iname \\*android\\*studio\\* -print -prune 首先运行 - > find ~ -path ~/Library/Caches/Metadata/Safari -prune -o -iname \\*android\\*studio\\* -print -prune

DELETE ALL FOLDERS related to android-studio 删除与android-studio相关的所有文件夹

start fresh install and project setup 开始全新安装和项目设置

回到之前的gradle版本我自己也面临过这样的问题,除非真的需要,否则不要使用RC gradle版本。

I encountered the same problem after upgrading to: 升级到后我遇到了同样的问题:

Android Studio 3.2 Canary 10
Build #AI-181.2784.17.32.4705630, built on April 6, 2018
JRE: 1.8.0_152-release-1136-b02 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.13.4

& Kotlin plugin 1.2.31 Kotlin plugin 1.2.31

I uninstalled the Kotlin plugin 我卸载了Kotlin插件

File | 档案| Invalidate Cache and restart 使缓存无效并重新启动

Reinstalled the latest Kotlin plugin 1.2.31 重新安装了最新的Kotlin插件1.2.31

File | 档案| Invalidate Cache and restart 使缓存无效并重新启动

Everything is now okay. 现在一切都还可以。

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

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