Android studio: Could not resolve com.android.tools.build:gradle:3.2.1

在Android Studio中导入旧项目时遇到编译错误:Couldnotresolvecom.android.tools.build:gradle:3.2.1。这通常由于网络问题导致无法从Google仓库下载依赖。为了解决这个问题,可以将build.gradle文件中的仓库地址改为阿里云的镜像源。关键更改包括添加阿里云的google()和jcenter()仓库。这样做能有效缓解因网络不佳导致的依赖下载失败问题。
部署运行你感兴趣的模型镜像

Android studio 导入旧项目,  编译时出现:
Could not resolve com.android.tools.build:gradle:3.2.1

原因可能是由于连接仓库 时,网络不太好

修改build.gradle,改成阿里云的仓库,注释Google 官方的仓库

    repositories {
//        mavenLocal()
//        jcenter()
//        maven {
//            url 'https://maven.google.com/'
//            name 'Google'
//        }
//        maven {
//            url 'http://maven.aliyun.com/nexus/content/repositories/releases/'
//        }

        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
    }

所以,关键是

maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }

您可能感兴趣的与本文相关的镜像

Stable-Diffusion-3.5

Stable-Diffusion-3.5

图片生成
Stable-Diffusion

Stable Diffusion 3.5 (SD 3.5) 是由 Stability AI 推出的新一代文本到图像生成模型,相比 3.0 版本,它提升了图像质量、运行速度和硬件效率

PS F:\mom-mls-pda> npx react-native run-android info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag. Jetifier found 1204 file(s) to forward-jetify. Using 8 workers... info JS server already running. info Installing the app... FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring project ':react-native-picker_picker'. > Could not resolve all artifacts for configuration ':react-native-picker_picker:classpath'. > Could not resolve com.android.tools.build:gradle:3.2.1. Required by: project :react-native-picker_picker > Could not resolve com.android.tools.build:gradle:3.2.1. > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'. > Could not HEAD 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'. > Connect to dl.google.com:443 [dl.google.com/172.217.26.174] failed: Connection timed out: connect * 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 BUILD FAILED in 1m 22s error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081 FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring project ':react-native-picker_picker'. > Could not resolve all artifacts for configuration ':react-native-picker_picker:classpath'. > Could not resolve com.android.tools.build:gradle:3.2.1. Required by: project :react-native-picker_picker > Could not resolve com.android.tools.build:gradle:3.2.1. > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'. > Could not HEAD 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'. > Connect to dl.google.com:443 [dl.google.com/172.217.26.174] failed: Connection timed out: connect * 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 BUILD FAILED in 1m 22s at makeError (F:\mom-mls-pda\node_modules\execa\index.js:174:9) at F:\mom-mls-pda\node_modules\execa\index.js:278:16 at processTicksAndRejections (node:internal/process/task_queues:96:5) at async runOnAllDevices (F:\mom-mls-pda\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:106:5) at async Command.handleAction (F:\mom-mls-pda\node_modules\@react-native-community\cli\build\index.js:192:9) info Run CLI with --verbose flag for more details. PS F:\mom-mls-pda>
最新发布
08-12
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值