26

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

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

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

Davis Broda
  • 4,102
  • 5
  • 23
  • 37
Nabdreas
  • 3,327
  • 4
  • 27
  • 30

16 Answers16

55

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

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

  1. Ctrl + Shift + "A"
  2. Type Gradle, then click Enter

You can toggle offline mode now

Pingolin
  • 3,161
  • 6
  • 25
  • 40
WhatAJerk
  • 579
  • 1
  • 5
  • 9
  • This should have been helpful, but for some reason it didn't alter the behavior. For me it started immediately after updating the A.Studio. (191.601...-> 192.620...) I uninstalled and installed the latest version and it continued failing, but it looks like blasting user settings on installation fixed it. (I uninstalled and installed twice, here, if that's unclear) This suggests that updating can mangle some relevant user settings, but I don't know enough about Gradle, yet, to work out the specifics. – The Nate Feb 25 '20 at 21:55
28

If you have Android Studio 3.6(Stable). You can switch between cached version and online version of gradle.

Look at the right side of the Android studio, you will see gradle tab. Click on it.

enter image description here

enter image description here

If you cannot see gradle tab then

enter image description here

26

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

Go to:

File > Settings > Build, Execution, Deployment > Compiler

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

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

Colibri
  • 713
  • 12
  • 16
6

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.

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.

Diaa Den
  • 1,024
  • 10
  • 5
4

Disable offline mode to solve this error.

In Android studio:

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

Then uncheck Offline work and sync again.

Hope your issue will resolved.

Sheikh Hasib
  • 7,423
  • 2
  • 25
  • 37
4

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

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

There you can find a Toggle Offline Mode Button

Toggle Offline Mode Button in Gradle

GiridharaSPK
  • 496
  • 7
  • 17
4

From Android Studio 4.1 there is a new location of the toggle offline mode.

enter image description here

Olga Konoreva
  • 1,338
  • 13
  • 20
3

In Android Studio 3.6 (or above) Click on the Gradle Button Which is at right side, it will open up small window, here click on the “Toggle Offline Mode” icon for enable or disable toggle. See below image for reference.

  • Shortcut key can also be set from settings as one is being shewn in image below that I've set.

Gradle Side menu with Offline toggle button

Umar Farooq
  • 331
  • 3
  • 6
2

You can toggle offline mode by opening the Gradle panel on your right, and click the following button : enter image description here

Jack'
  • 1,722
  • 1
  • 19
  • 27
2

I faced the same issue when I updated my old version to Android Studio 4.0.
I solved it this way first of all. Go To
File -> Settings -> Appearance & Behavior -> System Settings -> HTTP Proxy
and select the option Auto-detect proxy settings and then click OK as shown in the picture below

Select Auto-detect proxy settings

After that go to Gradle window in the right-side tool window and disable the Toggle Offline Mode as shown in the picture below

Disable Gradle offline mode

At the end sync the gradle by hitting the Try again button at the top of the code window

Sync Gradle again

When you click on Try again it will pop the proxy window you just need to click on the Yes button and don't change anything and that's it. Your issue will be fixed.

Sarmad Sohail
  • 245
  • 3
  • 6
1

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.

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

Uncheck Offline work and you should be fine.

enter image description here

Reaz Murshed
  • 23,691
  • 13
  • 78
  • 98
1

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:

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.

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

denisaT
  • 21
  • 4
1

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

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..

Naveen rana
  • 101
  • 6
1

I have different solutions since none of the above solution worked for me I don't know why (in macOS)

To disabled the offline mode since com.google.android.gms:play-services-base:17.1.0 No cached version available for offline mode

STEP: 1 Just make changes like

com.google.android.gms:play-services-base:17.1.1 in the gradle

STEP: 2 Which will pop Sync Now option

press Sync Now

STEP: 3 then in your build will appear (Disable offline mode and Sync)

Press Disabled offline mode and Sync and the offline mode will be disabled

STEP: 4 Change com.google.android.gms:play-services-base:17.1.1 to com.google.android.gms:play-services-base:17.1.0 then Sync again

It worked for me hope it helps you

Rahul Shakya
  • 1,269
  • 15
  • 15
0

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

This is working for me.

I updated Gradle version in build.gradle

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

and changed distributionUrl in gradle-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
Mr X
  • 1,053
  • 2
  • 11
  • 24
0

enter image description hereIn newer versions of android studio offline mode toggle button can be found here.enter image description here

You can even customize to a shortcut in keymap if necessary. Just search 'offline mode' in Settingings -> Keymap

Khamidjon Khamidov
  • 6,783
  • 6
  • 31
  • 62