Android 没有缓存版本的 gradle

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24144598/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 07:50:04  来源:igfitidea点击:

No cached version of gradle

androidandroid-studioandroid-gradle-plugin

提问by Nabdreas

I am getting this error when syncing gradle. I am pretty new to gradle so can't figure out what is the problem exactly?

同步gradle时出现此错误。我对 gradle 很陌生,所以无法弄清楚到底是什么问题?

Error:No cached version of com.android.tools.build:gradle:0.10.1 available for offline mode.

错误:没有缓存版本的 com.android.tools.build:gradle:0.10.1 可用于离线模式。

When I go to Setting->Gradle, I have offline mode ticked off and using default gradle wrapper.

当我转到 时Setting->Gradle,我勾选了离线模式并使用默认的 gradle 包装器。

回答by Colibri

In my case I also had an additional "offline switch" to the one in Gradle.

在我的情况下,我还有一个额外的“离线开关”到 Gradle 中的那个。

Go to:

去:

File > Settings > Build, Execution, Deployment > Compiler

There I've removed the --offlinein Command-line Options. Earlier I was trying to speed up Android Studio a bit and this was one of the changes I had made.

在那里我已经删除了--offlinein Command-line Options。早些时候我试图加快 Android Studio 的速度,这是我所做的更改之一。

Everything was fine after a restart then (and I have re-enabled both offline parts).

重启后一切正常(我已经重新启用了两个离线部分)。

回答by WhatAJerk

I have Android Studio 3.6 Beta 1, so there is no checkBox offline modein Gradle settings.

我有 Android Studio 3.6 Beta 1,所以offline modeGradle 设置中没有复选框。

If somebody can't find it as well, here is the answer:

如果有人也找不到它,这里是答案:

  1. Ctrl + Shift + "A"
  2. Type Gradle, then click Enter
  1. Ctrl + Shift + "A"
  2. 键入Gradle,然后单击Enter

You can toggle offline mode now

您现在可以切换离线模式

回答by Muhammad Ahmed Ali Baig

If you have Android Studio 3.6(Stable). You can switchbetween cached versionand online versionof gradle.

如果您有Android Studio 3.6(稳定版)。您可以切换之间的缓存版本在线版本的gradle产出的。

Look at the right sideof the Android studio, you will see gradletab. Click on it.

查看Android Studio的右侧,您将看到gradle选项卡。点击它。

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明

If you cannot see gradle tab then

如果您看不到 gradle 选项卡,则

enter image description here

在此处输入图片说明

回答by Diaa Den

This problem occurs, if you have offline mode switched on in your IDE and let the IDE upgrade your build file to use 0.10.1 of the gradle plugin (that is needed for the new AS version. Since you have never build with this version, it cannot be found in the offline cache.

如果您在 IDE 中打开了离线模式,并让 IDE 将您的构建文件升级为使用 0.10.1 的 gradle 插件(新 AS 版本需要。由于您从未使用此版本构建,则会出现此问题,在离线缓存中找不到它。

Go to File->Settings->Gradle (under Project Settings on the top) and disable the check in front of Offline Work (Section 'Global Gradle settings' at the bottom). Now it can download the version with the next build and afterwards you are free to use offline mode again, if you wish so.

转到 File->Settings->Gradle(在顶部的 Project Settings 下)并禁用 Offline Work 前面的检查(底部的“Global Gradle settings”部分)。现在它可以下载下一个版本的版本,之后你可以再次使用离线模式,如果你愿意的话。

回答by Hasib Akter

Disable offline modeto solve this error.

禁用离线模式以解决此错误。

In Android studio:

在安卓工作室:

File -> Other Settings -> Default Settings -> Build,Execution,Deployment -> Build Tools -> Gradle

File -> Other Settings -> Default Settings -> Build,Execution,Deployment -> Build Tools -> Gradle

Then uncheckOffline workand sync again.

然后取消选中Offline work并再次同步。

Hope your issue will resolved.

希望你的问题能得到解决。

回答by Naveen rana

From Android 3.6 below is the path to change the offline mode.

从 Android 3.6 下面是更改离线模式的路径。

New location to toggle Gradle's offline mode To enable or disable Gradle's offline mode, first select View > Tool Windows > Gradle from the menu bar. Then, near the top of the Gradle window, click Toggle Offline Mode Gradle offline button in the Gradle panel..

切换 Gradle 离线模式的新位置 要启用或禁用 Gradle 离线模式,首先从菜单栏中选择查看 > 工具窗口 > Gradle。然后,在 Gradle 窗口顶部附近,单击 Gradle 面板中的 Toggle Offline Mode Gradle offline 按钮。

回答by GiridharaSPK

I'm using Android Studio 3.6.3 I did not find the offline workoption in Settings

我正在使用 Android Studio 3.6.3 我没有找到offline work选项Settings

Select Gradle in View > ToolWindows > Gradleor search Gradle on CTRL + SHIFT + A

选择 Gradle inView > ToolWindows > Gradle或搜索 Gradle onCTRL + SHIFT + A

There you can find a Toggle Offline ModeButton

在那里你可以找到一个Toggle Offline Mode按钮

Toggle Offline Mode Button in Gradle

在 Gradle 中切换离线模式按钮

回答by Reaz Murshed

I thought I should post the latest update on where you should be able to find the option to disable your Offline Work in IntelliJ.

我想我应该发布最新的更新,你应该能够找到在 IntelliJ 中禁用离线工作的选项。

It's under your Preferences -> Build, Execution, Deployment

它位于您的首选项 -> 构建、执行、部署下

Uncheck Offline work and you should be fine.

取消选中离线工作,你应该没问题。

enter image description here

在此处输入图片说明

回答by denisaT

I've also encountered this issue and from Android Studio 3.6 the setting changed and can be found in another window. As stated here:

我也遇到过这个问题,从 Android Studio 3.6 开始,设置发生了变化,可以在另一个窗口中找到。如此处所述:

New location to toggle Gradle's offline mode To enable or disable Gradle's offline mode, first select View > Tool Windows > Gradle from the menu bar. Then, near the top of the Gradle window, click Toggle Offline Mode Gradle offline button in the Gradle panel.

切换 Gradle 离线模式的新位置 要启用或禁用 Gradle 离线模式,首先从菜单栏中选择查看 > 工具窗口 > Gradle。然后,在 Gradle 窗口顶部附近,单击 Gradle 面板中的 Toggle Offline Mode Gradle offline 按钮。

Here are the release notes: https://developer.android.com/studio/releases/#3.6-gradle-offline-ui

以下是发行说明:https: //developer.android.com/studio/releases/#3.6-gradle-offline-ui

回答by Mr X

I had the same problem in Android Studio v3.2.1.

我在 Android Studio v3.2.1 中遇到了同样的问题。

This is working for me.

这对我有用。

I updated Gradle version in build.gradle

我在build.gradle 中更新了 Gradle 版本

 dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'//same as Android Studio vesion           
 }

and changed distributionUrlin gradle-wrapper.properties

和改变distributionUrlgradle-wrapper.properties

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

to

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