Does Android studio need internet connection to build project - android-studio

I am using Android studio version 0.4.2 and gradle version 1.9. I have successfully installed Studio and have created multiple projects. Today when I launched Studio without internet connection,
I got this error message:
"Gradle project sync failed. Basic functionality (e.g. editing,
debugging) will not work properly" and the Event Log window shows
"Failed to refresh Gradle project < Project Name >. Connection timed
out: connect. If you are behind an HTTP proxy, please configure the
proxy settings either in IDE or Gradle."
I need to know if internet connection is mandatory for building projects using gradle.
I think gradle checks for latest version on internet and throws Connection time out error. If so, is there any workaround to disable that.

Currently Android Studio's Gradle implementation requires a fast stable network connection. For whatever reason, the developers have decided to force this requirement on users at this time. There is a setting that you should be able to use to utilize a local gradle installation, but it doesn't hold. The developers know about both the network requirement and the broken switch, but are currently prioritizing other functionality. They may remove that requirement in the 1.0 or post 1.0 time frame.
[see: https://plus.google.com/u/0/115692564989237473252/posts/LGSbniYqj3Q ]
Gradle's offline mode, isn't. It should be properly named cached mode. All that switch does is tell gradle to not try to go online and instead utilize cached copies of the various networked resources. Unfortunately that assumes that you have had (and will have again) a network connection, preferably a fast stable one. Using Android Studio (last version tested 0.5.9) with a slow/unstable network results in watching Android Studio process Gradle ( and Maven ) processes usually for 2-5 minutes, sometimes for 10 minutes or more. Also at seemingly random times when coding the IDE will lock up and the cause usually involves one or more Gradle processes that have spun up.
As a comparison, using IntelliJ IDEA 13.1 Community edition (the IDE that Android Studio is based on) I compared a default "Hello Android" IDE generated program using the Android Gradle wizard (substantially similar to the only one in Android Studio) and the Ant based Android wizard. The results were as expected. The gradle based project experienced the same painful lock up and lag that projects in Android Studio exhibited. The ant based Android project was near instantaneous. No appreciable delay once the project was created and opened. Coding caused no random lockups. Testing was done on a Windows 8.1 update1 Pro machine with a dual Athlon x2 processor, 6GB RAM, and a 6Mb/0.75Mb DSL connection. I believe that last part is most likely the issue.
Unfortunately until Android Studio removes the network requirement I feel it will be unusable to a large number of developers. That's a shame because otherwise it looks to be a marked improvement over the existing Eclipse based development environment.

For me, I had to check and then uncheck the box in
Preferences->Gradle->Offline work.
Then I got back online.

You can download the gradle distribution locally and build the project again.
To do this, edit your gradle-wrapper.properties under gradle-> wrapper in your Android project.
Edit the
distributionUrl=https://services.gradle.org/distributions/gradle-2.2.1-all.zip
to
distributionUrl=file:///home/foo/downloads/gradle-2.2.1-all.zip
So just download the file from here as mentioned in your gradle-wrapper.properties.

There's an offline mode preference in Preferences > Compiler > Gradle. If you already have your dependencies downloaded, this will generally work for you.

In Android studio version 1.5.1 I could solve this error by following steps :
1) Go to file -> Settings -> HTTP Proxy -> & select Auto detect proxy settings.
2) After that you may get Dialog to accept or reject certificate
3) Select Accept.
That's it.

Related

Android Studio Gradle Showing No Cached Version available

I have just updated to Android Studio 3.1.4 and now it is showing
"No cached version of com.android.tools.build:gradle:3.1.4 available for offline mode"
And if I turn off offline mode it is showing another error in loading dl.google.com/....
I want to run Android studio without Internet Connectivity.
How to solve this
You probably checked the offline mode in:
File -> Settings -> Build, Execution, Deployment -> Build Tools -> Gradle.
Uncheck the option Offline work and you'll be good to go.
Edit:
In fact, you’ll need to get connected to the internet for the first time downloading the dependencies-packages-meta files and etc. Then after, you’ll be able to use Android Studio offline if you don’t change the Build.gradle.

Android Studio 3.0 VERY VERY VERY slow on run

I have a very big problem using Android Studio.
Every time I make a code changing, I have to check if all has gone well launching my app; but as soon as I click the "Run app" or the "Apply changes", it's the end: it starts the Gradle build process, which take even 30 minutes to complete, and furthermore Android Studio take the full control of my computer, not allowing to do nothing anymore (like open the browser, open notepad++, and so on...).
Can anyone help me?
Thanks
If you use Eclipse you won't have this problem anymore. but if you want to stick with android studio and gradle you can run your emulator and gradle once and whenever you want to compile your code run it on the already built gradle. this means that do not close the emulator and run your program on it again and again. this way you will not have to spent alot of time on loading the emulator and gradle
Android Studio is not a very light software.It uses a lot of your system RAM and CPU power.So if you are using an old system then it is obvious that android studio will run slow.If possible then upgrade your system.
And one more thing it's better to use actual device rather than Virtual Emulator for our application working test.

Android Studio Gradle project refresh failed - Error host is down

I have tried many solutions to run Android Studio 2.3.3 on macOS 10.12 but this error still keeps showing and won't let me start a new project.
In the Event Log it says Gradle sync failed: Host is down. When I remove the gradle directories and invalidate caches it still has no effect.
Can anybody please suggest a way around this? All of the solutions I have seen posted in the forum haven't been successful so far.
Check your firewall settings to make sure it is not blocked. I have the same issue because I have blocked this with my firewall:
In my experience Android Studio requires an internet connection and unfettered access to the internet in order for you to develop anything. Hopefully this will improve with future versions.
There may be other ways to run the application without relying on Android Studio or gradle build process. One potential way might be to use the Unity platform. Otherwise you might try a google search for "build and run android app without gradle".

What links do we need enabled for Android Studio?

I'm working at a corporate location where we have restricted access to network. The hurdle that I'm facing is that I'm supposed to do some research on Android development and the network is not what I wanted it to be. I have installed Android Studio and created a new project. But as soon as the project is loaded, gradle sync operation starts and fails after not finding JUnit & similar dependencies.
I have already added the proxy settings in Android Studio and SDK manager, but I believe I'll have to request for unblocking some of the URLs that Android Studio needs access to. I couldn't find any such list, can someone please help me with the same?
I have tried running Fiddler to see which requests are being blocked, but I see only 1 URL and that is clients1.google.com but I'm not sure that is the only thing needed.
After lots of hits and misses, I have found the answer to this question. The build.gradle file for the project has the answer to this. It calls a function jcenter() which internally calls the libraries available at http://jcenter.bintray.com/. So, the entire list for Android Studio development including the SDK would be:
http://dl.google.com:443
http://dl-ssl.google.com:443
https://dl-ssl.google.com/android/repository/*
https://developer.android.com (for Android Studio downloads and documentations)
http://jcenter.bintray.com/
Thanks for all the help provided.

Wrong build being deployed on Android device using Visual Studio 2012 Xamarin.Android

I am using Visual Studio 2012 and Xamarin.Android Beta release to develop an Android application. When I try to deploy the android application for debugging purposes onto an Android device, it deploys the previously built application on the device and not the recent changes I made and deployed (i.e No refresh of build). However, if I use Xamarin Studio to do the same, it deploys the correct build everytime (i.e refreshes the build with new code changes).
Any idea why this is happening?
Thanks in advance!
I had a similar issue: With Visual Studio 2019 the debug version of my driver was deployed while building the release version.
The cause of my problem was, that in the Properties -> Driver Install -> Package Files I had an absolute path pointing to the debug version of my driver in the column File. This setting is valid for all configurations (not separated for debug/release), and when entering macros, they are immediately expanded to absolute paths.
I fixed this by editing the .vcxproj file with my favourite editor and changed the path back to $(TargetPath).
I had the same problem. My solution was to add "deploy" to the build configuration:
BUILD => Configuration Manager... => (select "Debug" from left-hand combo-box) => (tick "Deploy" in grid)
Courtesy of this xamarin forum post.
I have no idea why it does this, I had this issue before. I also noticed that the device log was somewhat behind (ie, at 3.30pm, the last record on the device log was 11.00am).
Uninstalling the app from the device and re-deploying it seems to correct it.
Note: I had this issue in VS, didn't check with XS.
I would look at the difference in your deployment settings in VS and XS (I think it may have something to do with the Fast Deployment option).
Similar question (though for iOS Simulator) here.
I had a similar problem (though on an Android emulator).
What didn't work for me:
restarting the computer
restarting Visual Studio
deleting bin / obj folders
going into Configuration Manager (Debug / Release / Configuration Manager) and ticking everything there - everything was ticked
changing the version of the app in the manifest
What worked for me?
Uninstalling the app from the emulator and then running Debug again.
It was an Android emulator, so I uninstalled by clicking on the app icon and holidng for long, and then dragging it to "Uninstall App". On an iOS simulator it should be similar.

Resources