关于Android studio sync不通过的问题。 Could not GET 'https://dl.google.com/dl/android/maven2.....

解决Android Studio Gradle同步问题
本文分享了解决Android Studio中Gradle同步失败的经验,包括下载正确的Gradle版本、配置代理及调整Gradle文件存放位置等步骤。

好久没用过AS之后,再次下载使用真的是问题百出。熬夜查度娘,晕过去之后,感谢老天开眼让我看到某博主写的解决方案给我了较大启发。https://blog.youkuaiyun.com/kane7csdn/article/details/84071008

我操作成功后的就是这样的

首先第一个问题就是Gradle Daemon的问题,主要是没有下载项目所需的 Gradle-**-** 版本文件。

一般文件地址在C:\Users\****\.gradle\wrapper\dists\...

在同步的时候,Gradle Daemon出错了就要去官网下载相应的版本文件。官网http://services.gradle.org/distributions/

对上补充:同步失败的话,划去的两个文件本来是没有生成的

 

如果Configure build 同步出错,那就是Gradle 版本匹配错误了!

去上面的Gradle官网下载最新的!最新的!最新的!(我不知道以后还会出什么版本)

最新的AS配最新的Gradle

官网http://services.gradle.org/distributions/

同时要保证项目中文件的版本同步。相对应的Android官方中Gradle的对应版本信息https://developer.android.google.cn/studio/releases/gradle-plugin#updating-plugin

然后就静等再次发起同步。

然后应该就差不多会成功了。

 

如果想要节省C盘资源,可以手动修改Gradle文件的位置

然后再存一下相关Http proxy 代理的信息,方便日后好用。

大连东软信息学院镜像服务器地址:

mirrors.neusoft.edu.cn 端口:80

SDK manager 不能下载的部分也可以到官网直接下载https://www.androiddevtools.cn/

 

折磨将近48小时,作为新手的真的痛苦。还有好多相关博主的方法也很有启发性。不方便贴出来,太多了!

向技术人员致敬。庆祝自己的第二篇博客。

项目的build.gradle.kts文件如下: buildscript { repositories { google() mavenCentral() maven { url = uri("https://maven.aliyun.com/repository/public") } maven { url = uri("https://dl.bintray.com/openinstall/maven")} } dependencies { classpath("com.android.tools.build:gradle:8.10.1") classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.22") } } repositories { google() } APP的build.gradle.kts文件如下: plugins { id("com.android.application") id("org.jetbrains.kotlin.android") } android { namespace = "com.example.gyppcx" // Kotlin DSL 使用等号赋值 compileSdk = 36 // 属性名是 compileSdk,compileSdkVersion defaultConfig { applicationId = "com.example.gyppcx" // 使用等号赋值 minSdk = 26 // 属性名是 minSdk,是 minSdkVersion //noinspection OldTargetApi,EditedTargetSdkVersion targetSdk = 34 // 属性名是 targetSdk,是 targetSdkVersion versionCode = 1 versionName = "1.0" } signingConfigs { create("release") { storeFile = file("../gyppcx.jks") storePassword = "Liu=123456" keyAlias = "key0" keyPassword = "Liu=123456" } } buildTypes { release { signingConfig = signingConfigs.getByName("release") isMinifyEnabled = false proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" ) } } compileOptions { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } kotlinOptions { jvmTarget = "17" } buildFeatures { compose = true } composeOptions { kotlinCompilerExtensionVersion = "1.5.10" } } // 添加依赖项(如果有) repositories { google() mavenCentral() maven { url = uri("https://maven.aliyun.com/repository/public") } maven { url = uri("https://dl.bintray.com/openinstall/maven")} } dependencies { implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) implementation("androidx.appcompat:appcompat:1.7.0") // 确保版本号与项目兼容 implementation("androidx.core:core-ktx:1.13.1") implementation("androidx.webkit:webkit:1.10.0") implementation("com.google.android.material:material:1.11.0") testImplementation("org.junit.jupiter:junit-jupiter:5.10.1") implementation("androidx.compose.ui:ui:1.7.0") implementation("androidx.compose.material3:material3:1.3.0") implementation("androidx.compose.ui:ui-tooling-preview:1.7.0") debugImplementation("androidx.compose.ui:ui-tooling:1.7.0") implementation("androidx.activity:activity-compose:1.8.2") } dependencies { //implementation(files("libs/OpenInstall_v2.8.5.jar")) // 添加这行 implementation("com.openinstall:openinstall-sdk:latest_version") implementation("androidx.appcompat:appcompat:1.7.0") // 确保版本号与项目兼容 implementation("androidx.core:core-ktx:1.13.1") implementation("androidx.webkit:webkit:1.10.0") implementation("com.google.android.material:material:1.11.0") testImplementation("org.junit.jupiter:junit-jupiter:5.10.1") implementation("androidx.compose.ui:ui:1.7.0") implementation("androidx.compose.material3:material3:1.3.0") implementation("androidx.compose.ui:ui-tooling-preview:1.7.0") debugImplementation("androidx.compose.ui:ui-tooling:1.7.0") implementation("androidx.activity:activity-compose:1.8.2") } repositories { maven { url = uri("https://maven.aliyun.com/repository/public") } } build sync时报错如下: Failed to resolve: com.openinstall:openinstall-sdk:latest_version build output时报错如下: FAILURE: Build completed with 10 failures. 1: Task failed with an exception. ----------- * What went wrong: Execution failed for task ':app:mergeReleaseNativeLibs'. > Could not resolve all files for configuration ':app:releaseRuntimeClasspath'. > Could not find com.openinstall:openinstall-sdk:latest_version. Searched in the following locations: - https://dl.google.com/dl/android/maven2/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom - https://repo.maven.apache.org/maven2/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom - https://maven.aliyun.com/repository/public/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom - https://dl.bintray.com/openinstall/maven/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom Required by: project :app * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more help at https://help.gradle.org. ============================================================================== 2: Task failed with an exception. ----------- * What went wrong: Execution failed for task ':app:checkReleaseDuplicateClasses'. > Could not resolve all files for configuration ':app:releaseRuntimeClasspath'. > Could not find com.openinstall:openinstall-sdk:latest_version. Searched in the following locations: - https://dl.google.com/dl/android/maven2/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom - https://repo.maven.apache.org/maven2/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom - https://maven.aliyun.com/repository/public/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom - https://dl.bintray.com/openinstall/maven/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom Required by: project :app * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more help at https://help.gradle.org. ============================================================================== 3: Task failed with an exception. ----------- * What went wrong: Execution failed for task ':app:checkReleaseAarMetadata'. > Could not resolve all files for configuration ':app:releaseRuntimeClasspath'. > Could not find com.openinstall:openinstall-sdk:latest_version. Searched in the following locations: - https://dl.google.com/dl/android/maven2/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom - https://repo.maven.apache.org/maven2/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom - https://maven.aliyun.com/repository/public/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom - https://dl.bintray.com/openinstall/maven/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom Required by: project :app * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more help at https://help.gradle.org. ============================================================================== 4: Task failed with an exception. ----------- * What went wrong: Execution failed for task ':app:mapReleaseSourceSetPaths'. > Could not resolve all files for configuration ':app:releaseRuntimeClasspath'. > Could not find com.openinstall:openinstall-sdk:latest_version. Searched in the following locations: - https://dl.google.com/dl/android/maven2/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom - https://repo.maven.apache.org/maven2/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom - https://maven.aliyun.com/repository/public/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom - https://dl.bintray.com/openinstall/maven/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom Required by: project :app * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more help at https://help.gradle.org. ============================================================================== 5: Task failed with an exception. ----------- * What went wrong: Execution failed for task ':app:mergeReleaseResources'. > Could not resolve all files for configuration ':app:releaseRuntimeClasspath'. > Could not find com.openinstall:openinstall-sdk:latest_version. Searched in the following locations: - https://dl.google.com/dl/android/maven2/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom - https://repo.maven.apache.org/maven2/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom - https://maven.aliyun.com/repository/public/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom - https://dl.bintray.com/openinstall/maven/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom Required by: project :app * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more help at https://help.gradle.org. ============================================================================== 6: Task failed with an exception. ----------- * What went wrong: Execution failed for task ':app:processReleaseMainManifest'. > Could not resolve all files for configuration ':app:releaseRuntimeClasspath'. > Could not find com.openinstall:openinstall-sdk:latest_version. Searched in the following locations: - https://dl.google.com/dl/android/maven2/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom - https://repo.maven.apache.org/maven2/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom - https://maven.aliyun.com/repository/public/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom - https://dl.bintray.com/openinstall/maven/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom Required by: project :app * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more help at https://help.gradle.org. ============================================================================== 7: Task failed with an exception. ----------- * What went wrong: Execution failed for task ':app:desugarReleaseFileDependencies'. > Could not resolve all files for configuration ':app:releaseRuntimeClasspath'. > Could not find com.openinstall:openinstall-sdk:latest_version. Searched in the following locations: - https://dl.google.com/dl/android/maven2/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom - https://repo.maven.apache.org/maven2/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom - https://maven.aliyun.com/repository/public/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom - https://dl.bintray.com/openinstall/maven/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom Required by: project :app * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more help at https://help.gradle.org. ============================================================================== 8: Task failed with an exception. ----------- * What went wrong: Execution failed for task ':app:mergeReleaseArtProfile'. > Could not resolve all files for configuration ':app:releaseRuntimeClasspath'. > Could not find com.openinstall:openinstall-sdk:latest_version. Searched in the following locations: - https://dl.google.com/dl/android/maven2/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom - https://repo.maven.apache.org/maven2/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom - https://maven.aliyun.com/repository/public/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom - https://dl.bintray.com/openinstall/maven/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom Required by: project :app * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more help at https://help.gradle.org. ============================================================================== 9: Task failed with an exception. ----------- * What went wrong: Execution failed for task ':app:mergeReleaseAssets'. > Could not resolve all files for configuration ':app:releaseRuntimeClasspath'. > Could not find com.openinstall:openinstall-sdk:latest_version. Searched in the following locations: - https://dl.google.com/dl/android/maven2/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom - https://repo.maven.apache.org/maven2/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom - https://maven.aliyun.com/repository/public/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom - https://dl.bintray.com/openinstall/maven/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom Required by: project :app * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more help at https://help.gradle.org. ============================================================================== 10: Task failed with an exception. ----------- * What went wrong: Execution failed for task ':app:collectReleaseDependencies'. > Could not resolve all files for configuration ':app:releaseRuntimeClasspath'. > Could not find com.openinstall:openinstall-sdk:latest_version. Searched in the following locations: - https://dl.google.com/dl/android/maven2/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom - https://repo.maven.apache.org/maven2/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom - https://maven.aliyun.com/repository/public/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom - https://dl.bintray.com/openinstall/maven/com/openinstall/openinstall-sdk/latest_version/openinstall-sdk-latest_version.pom Required by: project :app * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more help at https://help.gradle.org. ============================================================================== Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0. You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins. For more on this, please refer to https://docs.gradle.org/8.14.1/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation. BUILD FAILED in 5s
06-06
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值