Android Studio Gradle project refresh failed - Error host is down - android-studio

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

Related

AAPT: error: failed writing to 'c: ....\r.txt': The data is invalid. (13)

First off, I am a student learning the basics of app development in Android Studio. With that in mind, please don't answer in short hand, acronyms or other technical jargon as I probably won't know what you are saying.
I have tried several fixes that appear across the web for this issue. These fixes include, using the clean and rebuild options under Build in android studio. Fully uninstalling and reinstalling Android Studio, running the program and creating a new app and then looking for the error, the invalidate cache / restart option under file and changing the android gradle plugin version and gradle version under Build > edit build types > project tab. None of these have been successful.
The error popped up for me in September or early October after an update. I was able to create my hello world app and our first simple app without any issues. After the error appeared all apps refuse (including the ones that were working previously) to run or render in the emulator because of this error. I have spent hours of 'office hours' with the instructor who has years of experience with android studio and this has him stumped as well.
I have 2 weeks of this course left and a final project to create. I would be eternally grateful for a solution to this problem.
Thank you.

Downloading via SDK manager works but adding dependencies through gradle fails in android studio

I am currently facing some problems with android studio. It works fine when I download things via SDK manager or update android studio components but gradle dependencies download shows timeout after trying for some time. I have a decent internet connection. Cannot figure out where is the problem. Tried every configuration I know from windows firewall but nothing seems to work. I am not using any proxy.

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.

Android Studio doesn't open AVD and SDK Manager - "android.bat" not found

Short Story - Android Studio doesn't open AVD and SDK Manager all of a sudden. It throws an error 4:18:46 PM ProcessNotCreatedException: Cannot run program "C:\Users\xxxxx\AppData\Local\Android\android-studio1\sdk\tools\android.bat": CreateProcess error=2, The system cannot find the file specified:..
Long Story - This may sound impossible but here is what has happened. I have been using Studio for a week now and have been running a few AVDs since day 1. Today, I opened Studio again, executed my app on one AVD, closed AVD, made some changes, reexcuted my app and waited for available AVD dialog box to open.. but instead got above mentioned error. Just like that. I didn't do anything else. It was working like a minute ago. I checked various related questions on stackoverflow but couldn't solve it. Just thought of mentioning it if it helps solving the problem.
I checked various related locations and here is what I found - no android.bat, SDK Manager or AVD Manager. While I am surely interested in finding how they disappeared all of a sudden, I am currently more interested in fixing this issue (AVD and SDK Manager not opening).
C:\Users\xxxxx\AppData\Local\Android\android-studio1\sdk
C:\Users\xxxxx\AppData\Local\Android\android-studio1\sdk\tools
C:\Users\thakkap\AppData\Local\Android\android-studio1\sdk\tools\lib
C:\Users\xxxxx\AppData\Local\Android\android-studio1\sdk\build-tools
C:\Users\xxxxx\AppData\Local\Android\android-studio1\sdk\platform-tools
Probably somehow you just lost Android Sdk Tools which was installed before. Just download Android Sdk Tools again and you will be able to open sdk manager. Don't forget to run Android Studio as an administrator.

Does Android studio need internet connection to build project

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.

Resources