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

本文解决Flutter项目构建过程中遇到的“FAILURE: Build failed with an exception”错误,详细介绍了配置问题及解决方案,包括更换Maven仓库地址。

遇到的异常:

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'
        }

 

or

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'}

重新运行就可以了。

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值