no cached version available for offline mode

61,265

Solution 1

I had to dig for this a long time in the 2019.2 version. This option has moved in the UI. It is now in the toolbar of the gradle tools:

intellij gradle toolbar

see JetBrains documentation at https://www.jetbrains.com/help/idea/jetgradle-tool-window.html#offline

Solution 2

This Error occurs when in your Android Studio's Gradle Tools Offline Mode option is Enabled.

enter image description here

When Enabled it lookes like this.

enter image description here

To fix it, you can Disable mode by clicking on the option shown in below screenshot.

enter image description here

Solution 3


> Update: I heard Google Listened to the suggestion! and now in new android studio versions, when you start a new project, a popup will come with option to either build with gradle online or offline.. Great for you all..


You need to re-enable your gradle online mode

Google changed the location of doing this... After the latest version as at this time i am typing this answer, which is version below Android Studio 3.6.1 built on February 27, 2020

I have sent a message to the them so Google changes this in next update..Cos the new location confuses the Software engineers who are used to the old way of doing it... But for now follow these clear 2 steps to find it and toggle it Online or Offline easily..

  1. Just Go to the top-right hand corner of your SDK and click the vertical Gradle tab as circled in red in the my picture below... step1

  2. Then you Click this icon (which looks like a symbol in an electrical schematic circuit) on the gradle table that comes out.. As Circled in Red in my picture below.. Image of what you must toggle

Solution 4

Maybe helps someone. Just remove --offline in "Command-line Options:"

enter image description here

Solution 5

It seems that in newer versions of IntelliJ (I am on 2018.1) you may need to uncheck the Offline checkbox in Gradle preferences.

Gradle Prefences Screenshot

Share:
61,265
Mufaddal Gulshan
Author by

Mufaddal Gulshan

Updated on December 12, 2021

Comments

  • Mufaddal Gulshan
    Mufaddal Gulshan over 2 years

    At office, I am behind a proxy. The internet access is restricted.

    So I performed a gradle sync at home and copied the folder ".gradle" present at C:\Users\username.gradle from my home PC to the same location on my office PC.

    Now on my office PC, I set gradle in Android Studio to "Work Offline" but still whenever I try to perform a gradle sync, I get an error stating

    Error: Could not download google-services.jar (com.google.gms:google-services:3.0.0): No cached version available for offline mode
    

    However on digging through the ".gradle" folder I was able to locate the google-service.jar file at

    C:\Users\username\.gradle\caches\modules-2\files-2.1\com.google.gms\google-services\3.0.0\32b833222c886ecfb37d79b1a05ce1eddb702db1
    

    I am not sure how to proceed. Please help.

  • Reza Taghizadeh
    Reza Taghizadeh almost 5 years
    realy? what amusung news
  • Ocie Mitchell
    Ocie Mitchell over 4 years
    2019.2 ultimate looks entirely different when I open the gradle section and I don't see an offline section. Maybe I have this setting somewhere else.
  • Declan Nnadozie
    Declan Nnadozie over 4 years
    @NevinChen i wanted to ditch it entirely, and use eclipse.. People are use to settings
  • Sascha
    Sascha over 4 years
    Wow thanks for the find, I didn't even see the button. It was hidden since my Gradle sidebar was to narrow.
  • Dennis Gloss
    Dennis Gloss over 4 years
    Thanks! It switched to online mode!
  • Almeida
    Almeida over 4 years
    in my case was a command-line options, take a look into it stackoverflow.com/a/59376069/2238515
  • Jonik
    Jonik about 4 years
    No, it shouldn't, this answer is for a different question entirely! The OP needs to work in offline mode due to restricted internet and is trying to get it to work.
  • Mohamed Ibrahim
    Mohamed Ibrahim about 4 years
    Thanks for posting these steps. Unfortunately, this is not available in the latest android studio. So we can follow this stackoverflow.com/a/59133393/2219406
  • Mujahid Khan
    Mujahid Khan about 4 years
  • princebillyGK
    princebillyGK over 3 years
    Thanks only this answer works for me. And a great shortcut too.
  • user25
    user25 over 3 years
    I have empty string here, so not
  • Edward Falk
    Edward Falk over 2 years
    Well it solved my problem, so I'm happy. Worth noting: the icon doesn't change when you click it other than to have the background change from grey to clear. That confused me for a bit.
  • Serg Burlaka
    Serg Burlaka about 2 years
    thanks It helps me