Whenever I try to open a project or Create a new project in Android Studio, I encounter a Gradle Project Sync error. Android Studio is displaying an error which states "Connection to The Internet Denied". I searched the possible solutions on Stack Overflow and also the Android Developers Website, but was not successful.
I tried all the possible solutions given in the following posts and documentation, but none of them worked for me.
- Create new project on Android, Error: Studio Unknown host 'services.gradle.org'
- Android Studio Connection Refused
- https://developer.android.com/studio/troubleshoot.html
- Android Studio internet connection
Here are the build.gradle and gradle.properties files:
build.gradle -
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
gradle.properties -
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Djava.net.preferIPv4Stack=true
systemProp.https.proxyHost=localhost
systemProp.https.proxyPort=8080
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
When I use localhost as my ProxyHost, it throws an error saying Connection Refused: connect
Could somebody guide me in fixing this error? Thanks in Advance.