I am using Windows 10, and just installed Android Studio Arctic Fox Patch 2 (following a Udemy course), and created a new project with a new Android Phone activity "Empty activity".
And when I try to click on "Gradle Sync", the IDE tries to download gradle pom for about 2 minutes and then fails with:
Read timed out
I also cannot add any Android Virtual devices as the Internet connection is missing according to the IDE, and it cannot fetch the list of possible Virtual Devices.
I am going crazy since 2 days. I am not using proxy, my Internet download speed is 120Mb, upload is 5Mb, video calls are working normally. I have not changed any project configuration, I am not using a Proxy.
- there are no Proxy settings in my Windows configuration
- there is no global
gradle.properties
file where I could have those proxy settings set (I did a global file search). The project's file does not have any proxy settings (it is generated by the IDE anyway) - I have tried adding Android Studio (the exes inside the
bin
folder the the Firewall exceptions) - I have tried disabling Windows Firewall alltogether
- I have tried rebooting with
msconfig
and only the basic Windows services (so no startup apps) - also tried this: BASE FILTERING ENGINE service issues: ERR_NETWORK_ACCESS_DENIED and Can not start internal HTTP server
- also tried this: Android studio "Cannot start internal HTTP server"
Full stack trace:
Starting Gradle Daemon...
Gradle Daemon started in 4 s 286 ms
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'My First APp'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:7.0.2.
Required by:
project :
> Could not resolve com.android.tools.build:gradle:7.0.2.
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/7.0.2/gradle-7.0.2.pom'.
> Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/7.0.2/gradle-7.0.2.pom'.
> Read timed out
> Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20.
Required by:
project :
> Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20.
> Could not get resource 'https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.5.20/kotlin-gradle-plugin-1.5.20.pom'.
> Could not GET 'https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.5.20/kotlin-gradle-plugin-1.5.20.pom'.
> Read timed out
* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project 'My First APp'.
at org.gradle.configuration.project.LifecycleProjectEvaluator.wrapException(LifecycleProjectEvaluator.java:75)
at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:68)
at org.gradle.configuration.project.LifecycleProjectEvaluator.access$400(LifecycleProjectEvaluator.java:51)
at org.gradle.configuration.project.LifecycleProjectEvaluator$EvaluateProject.lambda$run$0(LifecycleProjectEvaluator.java:102)
at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.lambda$applyToMutableState$0(DefaultProjectStateRegistry.java:250)
at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.lambda$withProjectLock$3(DefaultProjectStateRegistry.java:310)
(...) org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor.copyToCache(DefaultCacheAwareExternalResourceAccessor.java:199)
... 48 more
Caused by: java.net.SocketTimeoutException: Read timed out
Can anyone help me?
Maybe more information, settings.gradle
:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
}
}
rootProject.name = "My First APp"
include ':app'
build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
inner build.gradle
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.myfirstapp"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
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=-Xmx2048m -Dfile.encoding=UTF-8
# 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
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
[Bonus information]
The whole thing started working yesterday after I set in my IDE "Automatically detect Proxy settings" instead of "No Proxy", without providing any settings. But then I had to re-install my Android Studio to match the version of the one from the course, and that trick from yesterday is not working anymore. Perhaps that setting in IDE was just a coincidence, but then I have no idea why it worked then and not now.
How can I debug it? I already had similar issues with Docker and Kubernetes development, where I spent a month before giving up. Maybe this is something Windows-specific? How can I stop Windows from blocking the outgoing connections?