Failed to build Android Hello World application in offline mode

12,087

Solution 1

Though you can now build Gradle projects without an active internet connection, you still need to download the dependencies once before offline mode will work. If you don't build once with offline mode disabled, you won't have any of the dependencies on your system and the build will fail.

From the Android Studio 0.4.0 release notes:

Note that if you add a new dependency you'll still need to have a network connection to download the artifact. If you somehow forget that you are in offline mode, there is a balloon tip for that.

The Building the Android Gradle Plugin page includes instructions for manually getting the Gradle build tools.

Solution 2

Had the same error after updating Android Studio today. For me, it wasn't a matter of proxy settings:

Uncheck "Offline work" in File>Settings>Gradle>Global Gradle Settings and resync the project, for example by restarting your Android Studio IDE. Once synced, you can check the option again to work offline (Gradle version 0.11... and Android Studio version 0.6.0 Preview).

Solution 3

Go to Preferences > Gradle > Offline work

Make sure you unchecked Offline Work. I had same problem, and that works fine.

Share:
12,087
PermanentGuest
Author by

PermanentGuest

Updated on June 17, 2022

Comments

  • PermanentGuest
    PermanentGuest almost 2 years

    I'm new to Android development. I work on a system that doesn't have an internet connection. I have installed the new Android Developer studio which claims to be supporting offline development. I have updated the Gradle to 1.9 (by copying the downloaded zip file to the folder "C:\Documents and Settings\.gradle\wrapper\dists\gradle-1.9-all\3jdgemv0iv8uqohg3kcp2o88r1". It is clear that the developer studio did detect this and unpacked the gradle in that folder.

    After this I created a new HelloWorld project and tried to build it, I get the following error.

    Gradle: A problem occurred configuring project ':app'.
    
    > Could not resolve all dependencies for configuration ':app:classpath'.
    
       > Could not resolve com.android.tools.build:gradle:0.7.+.
         Required by:
            HellowWorld1:app:unspecified
    
          > No cached version of com.android.tools.build:gradle:0.7.+ available for offline mode.
    

    Do you know what is causing this? How do I solve this? Is there any other file which I should update with the information w.r.t the manually installed Gradle version?

  • PermanentGuest
    PermanentGuest over 10 years
    But how can I know which are the dependencies? Are they listed somewhere? If yes, probably I could download and install manually(?)
  • Bryan Herbst
    Bryan Herbst over 10 years
    They are listed in your build.gradle file.
  • PermanentGuest
    PermanentGuest over 10 years
    OK, thank you. However, the additional dependency is about Maven which I was not sure if related to the above error. But from other forumns I understood that I have to install a local repository of Maven to get it working offline. There are some procedures to install Maven locally. When I execute them, again it looks to download further dependencies. So, to me it looks getting this done beyond my current level of experience. I will find a way to connect the machine to internet. Thanks for your help.
  • maximede
    maximede about 8 years
    Well, OP still needs to have the dependencies somewhere in the first place