Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android-Studio: Gradle projects won't build without internet connectivity even in "Offline Mode"

I've recently shifted to Android-Studio from Eclipse simply because of it's automatic code completion feature which I fell in love with. But Android Studio is giving me a hard time from the moment I installed. It is laggy, it freezes often, but the main problem is that it does NOT build my projects without connecting to the internet. I found this question where I found that we can build gradle projects without connecting it to the internet by enabling the "Offline Mode" but it doesn't work for me. Even if I set gradle to local distribution mode, Android Studio automatically changes it to default settings, which is really annoying. I've no idea what's wrong with Android Studio. I'm using version 0.4.6.

The event log shows this -

11:13:26 PM AssertionError: Already disposed: Already disposed
11:13:42 PM Failed to refresh Gradle project 'Study Buddy'
        Unknown host 'repo1.maven.org'.
        Please ensure the host name is correct. If you are behind an HTTP proxy, please configure the proxy settings either in IDE or Gradle.
        HTTP proxy settings Open Gradle documentation

However, when I connect to the internet gradle builds the projects without any error. But I want to use Android-Studio in Offline Mode since I've a really low bandwidth. Please help to fix this issue.

like image 264
Swap Avatar asked Apr 22 '14 17:04

Swap


People also ask

Does Gradle build require internet connection?

Gradle needs an internet connection to download the dependencies that you specify. Once it downloads everything, it can put them in memory so that you can work offline. To do this, you need to go to Files->Settings (For Mac: Android Studio-> Settings...). You can now build your project without internet.

How do I set Gradle to work offline?

In Gradle command line interface you can get this done by using --offline flag. Specifies that the build should operate without accessing network resources.


1 Answers

Offline mode works only after you've compiled one time online. I know, it doesn't make complete sense if you don't understand everything on how Gradle works. But, you have to compile one time online and then it works.

This of course is a moot point if you don't have access to an internet connection at the time you wish to compile. Or, if you're like me, it just doesn't work due to your company's proxy and firewall rules.

I did get it to work at my company but the latest upgrade broke it. And now, even the previous version doesn't work, but I think that was my company as well. They pushed out some "patches" and I think that's what broke it.

like image 106
bolski Avatar answered Nov 04 '22 18:11

bolski