I want to add some code to my settings.gradle file
if (!hasInternetAccess()) {
startParameter.offline=true
}
to allow gradle-code compilation if my computer has no internetconnection.
does anybody know how a gradle script can implement hasInternetAccess()?
Background: gradle or android studios compilation fails if the computer has no internet connection because it could not look for updated dependencies.
instead of manually invoking gradle with the "--offline" parameter
or adding
startParameter.offline=true
to the settings.gradle file i am looking for a way to automate the configuration
[update]
i followed @opal-s link and added these lines to my settings.gradle file:
boolean isReachable = java.net.InetAddress.getByName("www.google.com").isReachable(1500)
print "has internet: " + isReachable
in the debug output i always get
has internet: false
although i can successfully ping www.google.com