I have no idea what I changed in my project, but it suddenly cannot get past this step while building gradle scripts.
There is no problem building it with j
I fixed mine by copying the Gradle settings in a working project and pasting them into the bad build.gradle file.
I've encountered this problem far too frequently since i switched over to Android Studio. This is indeed an issue with the repository not being accessible - either due to a network issue or, more likely, the repo being down for whatever reason.
The simplest work-around that I've found is to just select the "work offline" mode within the Android Studio preferences. This doesn't help if you need to add a new dependency, but if you already have all your dependencies added it does the trick.
To enable this setting go to:
Preferences -> Gradle
In the right side options go down to "Global Gradel Settings" and check the "Offline work" box.
The box should look like:
You can periodically uncheck this box to see if the repo is back online.
NOTE: This option is the equivalent of setting the --offline flag when running a gradle build from the command line.
Check http://bintray.com (jcenter
) or http://maven.org (mavenCentral
) from your browser and change repositories
setting in the build.gradle
according to available site.
I've got similar problem today, and in my case I found it is because one of my external dependencies have difficulty being pulling from the internet.
Here's how I solved it:
Step 1
Check the dependencies
in build.gradle
files in the app (or the library modules, according to where your problem occured).
For example, it might look like this:
dependencies {
...
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.amazonaws:aws-android-sdk-iot:2.2.20'
}
Step 2
Guess which ones might be the root cause (ie. the one which looks harder to pull).
In my case, I think 'com.amazonaws:aws-android-sdk-iot:2.2.20'
looks suspicious, so I comment it out and then try to build Gradle again. This time, the Gradle build is successful.
Step 3
Search for other artifact versions.
In my case, I searched
https://bintray.com/bintray/jcenter/com.amazonaws%3Aaws-android-sdk-iot
and found 2.2.21
, 2.2.22
are also available (currently).
I tried 2.2.21
in my build.gradle
, and the Gradle build works now!!
dependencies {
...
compile 'com.amazonaws:aws-android-sdk-iot:2.2.21'
}
Other References
To know more about external dependencies in Gradle, check these sites:
If you are using a proxy server then you might have to set the JVM parameters for your proxy.
Settings -> Gradle -> Gradle VM options: -Dhttp.proxyHost=1.2.3.4 -Dhttp.proxyPort=8080 Settings -> Compiler -> VM options: -Dhttp.proxyHost=1.2.3.4 -Dhttp.proxyPort=8080
I had to restart the IDE for these settings to take effect.
Just providing my experience in case others run into the following scenario.
The problem for me was one of my repositories was hosted on my companies network and not the public network. After VPN'ing I was able to "resolve the dependency."