I am getting this error in android studio 3.0.
<Unknown host \'dl.google.com\' You may need to adjust the proxy settings in Gradle
This problem usually occurs when we change your project from one pc to another . the proxy of the system is disabled and the solution that worked for me is : File > Settings > Appearance & Behavior > System Settings > HTTP Proxy [Under IDE Settings] Enable following option Auto-detect proxy settings
you just need to reconnect your phone with android studio and then install or run your program
Your system needs to be online at the time you are building the project first time for the dependencies you have added. Dependencies are downloaded from the google and jcenter servers. After you build the project then you don't need internet connection because dependencies will be available offline.
This error appears if its have not compatible versions of Android Gradle plugin and Gradle wrapper. This versions works for me:
project_dir/build.gradle
buildscript {
dependencies {
classpath('com.android.tools.build:gradle:3.5.1')
}
}
project_dir/gradle/wrapper/gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Basically when u add some new dependencies you require an internet connection to download the dependencies from the internet. By default the Android Studio as set the option to connecting to the internet to get a proper flow. But if u cant connect to the internet, work with the gradle in offline mode and later when the internet comes again...it will automatically download the necessary files in background!
Solution: Click on Enable gradle offline mode and sync the project!
In my case this worked:
File>invalid caches/restart >invalid and restart