Could not download kotlin-reflect.jar (org.jetbrains.kotlin:kotlin-reflect:1.3.41)

遇到的異常:

FAILURE: Build failed with an exception.

* Where:
Build file 'D:\flutter_workspace\chapter4\android\app\build.gradle' line: 26

* What went wrong:
A problem occurred evaluating project ':app'.
> Could not resolve all artifacts for configuration 'classpath'.
   > Could not download kotlin-reflect.jar (org.jetbrains.kotlin:kotlin-reflect:1.3.41)
      > Could not get resource 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-reflect/1.3.41/kotlin-reflect-1.3.41.jar'.
         > Read timed out

* 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 3m 0s
Finished with error: Gradle task assembleDebug failed with exit code 1
 

二、解決方案:

出問題的位置:Android 項目 build.gradle 中

apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

解決方法一:

科學上網

 

解決方法二:

找到fullter sdk 中這個路徑下的文件:D:\tools\flutter\packages\flutter_tools\gradle\flutter.gradle

如下修改代碼:

buildscript {
    repositories {
        google()
        //jcenter()
        maven{
            url 'https://maven.aliyun.com/repository/jcenter'
        }
        maven{
            url 'http://maven.aliyun.com/nexus/content/groups/public'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
    }
}

Android 項目中的build.gradle中使用的maven倉庫也做修改:

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

重新運行就可以了。

 

 

發佈了48 篇原創文章 · 獲贊 7 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章