flutter踩坑01:下载包失败:Could not resolve all artifacts for configuration....
flutter踩坑01:下载包失败:Could not resolve all artifacts for configuration....
flutter在下载依赖失败或者flutter run运行的时候出现某个jar或者文件下载失败的时候,如下:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':url_launcher'.
> Could not resolve all artifacts for configuration ':url_launcher:classpath'.
> Could not download kotlin-reflect.jar (org.jetbrains.kotlin:kotlin-reflect:1.3.31)
> Could not get resource 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-reflect/1.3.31/kotlin-reflect-1.3.31.jar'.
> Could not GET 'https://d29vzk4ow07wi7.cloudfront.net/a0172daf57e511e8e0df9251b508db8aa6b885cdf0c5849addc9b840db4814f0?response-content-disposition=attachment%3Bfilename%3D%22kotlin-reflect-1.3.31.jar%22&Policy=eyJTdGF0ZW1lbnQiOiBbeyJSZXNvdXJjZSI6Imh0dHAqOi8vZDI5dnprNG93MDd3aTcuY2xvdWRmcm9udC5uZXQvYTAxNzJkYWY1N2U1MTFlOGUwZGY5MjUxYjUwOGRiOGFhNmI4ODVjZGYwYzU4NDlhZGRjOWI4NDBkYjQ4MTRmMD9yZXNwb25zZS1jb250ZW50LWRpc3Bvc2l0aW9uPWF0dGFjaG1lbnQlM0JmaWxlbmFtZSUzRCUyMmtvdGxpbi1yZWZsZWN0LTEuMy4zMS5qYXIlMjIiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE1ODYyNTYzNDF9LCJJcEFkZHJlc3MiOnsiQVdTOlNvdXJjZUlwIjoiMC4wLjAuMC8wIn19fV19&Signature=g7IpNFZ30ml7BofrDRqxvVTOidUqrfYgiNEb4ykjpCzmiRKMLPNV19Zy09LSxB5zwo2bYkmGNyvVqBKiYL26uuTtFER5t5Z7YcQPfmb220WviYE~3fuSMLA84FAPTwweRwEO1ZXHWmMupgMO41ao6XfCzd9zSEzPC5o5yWXne4GZSPShEVmgHOg8nhL5G8WD5nUOQNxu9VeO7npIRzU5d6XkrB~pSPKkMkRNisl0LcxjuljT6FKbGtfnhm2uYvpGVNaDvIeff3Qp9Bx3gdmxBH6-AbzS-GxVf1xIBtzzoBqUyq6raz27mL8TIX7mROGomvOV0z5MhlRnG1Kl21UVIw__&Key-Pair-Id=APKAIFKFWOMXM2UMTSFA'.
> d29vzk4ow07wi7.cloudfront.net
> Could not download kotlin-stdlib.jar (org.jetbrains.kotlin:kotlin-stdlib:1.3.31)
> Could not get resource 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib/1.3.31/kotlin-stdlib-1.3.31.jar'.
> Could not GET 'https://d29vzk4ow07wi7.cloudfront.net/f38c84326543e66ed4895b20fb3ea0fca527fd5a040e1f49d0946ecf3d2b3b23?response-content-disposition=attachment%3Bfilename%3D%22kotlin-stdlib-1.3.31.jar%22&Policy=eyJTdGF0ZW1lbnQiOiBbeyJSZXNvdXJjZSI6Imh0dHAqOi8vZDI5dnprNG93MDd3aTcuY2xvdWRmcm9udC5uZXQvZjM4Yzg0MzI2NTQzZTY2ZWQ0ODk1YjIwZmIzZWEwZmNhNTI3ZmQ1YTA0MGUxZjQ5ZDA5NDZlY2YzZDJiM2IyMz9yZXNwb25zZS1jb250ZW50LWRpc3Bvc2l0aW9uPWF0dGFjaG1lbnQlM0JmaWxlbmFtZSUzRCUyMmtvdGxpbi1zdGRsaWItMS4zLjMxLmphciUyMiIsIkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTU4NjI1NjM5MX0sIklwQWRkcmVzcyI6eyJBV1M6U291cmNlSXAiOiIwLjAuMC4wLzAifX19XX0_&Signature=MgenmHLDSO66gc2YAaf1l6L9eQjg9xBAKROmoMwEP9-FUACk9uUXgD6CS~2uj1jAlKUFap88Uo50C5z47EAirrxFeQnjrkrQ2epdPGVCYlWJ~lF9IJShpYJpOifd27MwWUFZQpKq1OT5Ahn0eCFWMoZLasji1rg~indBd3nwqfu4ewXZVpkZhsna~bDkSolIHQ3CVAYbsdkOxsHQEFx92WQNGdgj-AMjoC5JoTitlXNPqgMrh4QQ4PwKsdOaXPleSna7~kCmbl7iFPlCRBtGQKYb87pvgpIOM09rX4DpMYGXew47dZLeML0fAHdb2AQ2SYI3LASEGC > d29vzk4ow07wi7.cloudfront.net
> Could not get unknown property 'android' for project ':url_launcher' of type org.gradle.api.Project.
> Could not find method implementation() for arguments [project ':url_launcher_web'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
> Could not find method implementation() for arguments [project ':url_launcher_macos'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
* 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
步骤1:更新项目的依赖
打开项目的 android/build.gradle
文件,将里面的两个repositories
改为
repositories {
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'
}
google()
jcenter()
}
步骤2:将下载失败的包的依赖修改
A problem occurred configuring project ':url_launcher'.
可以看出url_launcher
下载依赖失败了;
- 打开flutter的sdk文件夹,进入
/.pub-cache\hosted
,里面的文件夹是各个镜像库,在mirrors.tuna.tsinghua.edu.cn
文件夹(没有的话就是其他文件夹)中找到url_launcher
; - 进入里面的
android/build.gradle
文件,和上一步一样的替换两个repositories
,这个依赖在下载依赖的时候,就会从阿里云的镜像库下载,就能下下来了.