flutter-环境及配置等问题汇总

这篇博客汇总了Flutter开发中遇到的环境配置问题,包括kotlin-reflect.jar下载失败和安卓端运行时的artifact配置问题,提供了详细的解决步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、Could not download kotlin-reflect.jar (org.jetbrains.kotlin:kotlin-reflect:x.x.x

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'gradleOut'.
> Could not resolve all files for configuration ':classpath'.
> Could not download kotlin-reflect.jar (org.jetbrains.kotlin:kotlin-reflect:1.1.3-2)
> Could not get resource 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-reflect/1.1.3-2/kotlin-reflect-1.1.3-2.jar'.
> Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-reflect/1.1.3-2/kotlin-reflect-1.1.3-2.jar'.
> d29vzk4ow07wi7.cloudfront.net
> Could not download kotlin-stdlib.jar (org.jetbrains.kotlin:kotlin-stdlib:1.1.3-2)
> Could not get resource 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib/1.1.3-2/kotlin-stdlib-1.1.3-2.jar'.
> Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib/1.1.3-2/kotlin-stdlib-1.1.3-2.jar'.
> d29vzk4ow07wi7.cloudfront.net
> Could not download protobuf-java.jar (com.google.protobuf:protobuf-java:3.0.0)
> Could not get resource 'https://jcenter.bintray.com/com/google/protobuf/protobuf-java/3.0.0/protobuf-java-3.0.0.jar'.
> Could not GET 'https://jcenter.bintray.com/com/google/protobuf/protobuf-java/3.0.0/protobuf-java-3.0.0.jar'.
> d29vzk4ow07wi7.cloudfront.net
> Could not download bcpkix-jdk15on.jar (org.bouncycastle:bcpkix-jdk15on:1.56)
> Could not get resource 'https://jcenter.bintray.com/org/bouncycastle/bcpkix-jdk15on/1.56/bcpkix-jdk15on-1.56.jar'.
> Could not GET 'https://jcenter.bintray.com/org/bouncycastle/bcpkix-jdk15on/1.56/bcpkix-jdk15on-1.56.jar'.
> d29vzk4ow07wi7.cloudfront.net
> Could not download bcprov-jdk15on.jar (org.bouncycastle:bcprov-jdk15on:1.56)
> Could not get resource 'https://jcenter.bintray.com/org/bouncycastle/bcprov-jdk15on/1.56/bcprov-jdk15on-1.56.jar'.
> Could not GET 'https://jcenter.bintray.com/org/bouncycastle/bcprov-jdk15on/1.56/bcprov-jdk15on-1.56.jar'.
> d29vzk4ow07wi7.cloudfront.net
> Could not download fastutil.jar (it.unimi.dsi:fastutil:7.2.0)
> Could not get resource 'https://jcenter.bintray.com/it/unimi/dsi/fastutil/7.2.0/fastutil-7.2.0.jar'.
> Could not GET 'https://jcenter.bintray.com/it/unimi/dsi/fastutil/7.2.0/fastutil-7.2.0.jar'.
> d29vzk4ow07wi7.cloudfront.net
> Could not download ecj.jar (org.eclipse.jdt.core.compiler:ecj:4.6.1)
> Could not get resource 'https://jcenter.bintray.com/org/eclipse/jdt/core/compiler/ecj/4.6.1/ecj-4.6.1.jar'.
> Could not GET 'https://jcenter.bintray.com/org/eclipse/jdt/core/compiler/ecj/4.6.1/ecj-4.6.1.jar'.
> d29vzk4ow07wi7.cloudfront.net
> Could not download jimfs.jar (com.google.jimfs:jimfs:1.1)
> Could not get resource 'https://jcenter.bintray.com/com/google/jimfs/jimfs/1.1/jimfs-1.1.jar'.
> Could not GET 'https://jcenter.bintray.com/com/google/jimfs/jimfs/1.1/jimfs-1.1.jar'.
> d29vzk4ow07wi7.cloudfront.net
> Could not download lombok-ast.jar (com.android.tools.external.lombok:lombok-ast:0.2.3)
> Could not get resource 'https://jcenter.bintray.com/com/android/tools/external/lombok/lombok-ast/0.2.3/lombok-ast-0.2.3.jar'.
> Could not GET 'https://jcenter.bintray.com/com/android/tools/external/lombok/lombok-ast/0.2.3/lombok-ast-0.2.3.jar'.
> d29vzk4ow07wi7.cloudfront.net
> Could not download guava.jar (com.google.guava:guava:22.0)
> Could not get resource 'https://jcenter.bintray.com/com/google/guava/guava/22.0/guava-22.0.jar'.
> Could not GET 'https://jcenter.bintray.com/com/google/guava/guava/22.0/guava-22.0.jar'.
> d29vzk4ow07wi7.cloudfront.net
> Could not download antlr4.jar (org.antlr:antlr4:4.5.3)
> Could not get resource 'https://jcenter.bintray.com/org/antlr/antlr4/4.5.3/antlr4-4.5.3.jar'.
> Could not GET 'https://jcenter.bintray.com/org/antlr/antlr4/4.5.3/antlr4-4.5.3.jar'.
> d29vzk4ow07wi7.cloudfront.net
> Could not download juniversalchardet.jar (com.googlecode.juniversalchardet:juniversalchardet:1.0.3)
> Could not get resource 'https://jcenter.bintray.com/com/goo...rsalchardet/1.0.3/juniversalchardet-1.0.3.jar'.
> Could not GET 'https://jcenter.bintray.com/com/goo...rsalchardet/1.0.3/juniversalchardet-1.0.3.jar'.
> d29vzk4ow07wi7.cloudfront.net

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 2m 1s
]

解决办法:

buildscript {
    ext.kotlin_version = '1.2.71'
    repositories {
    	//替换为阿里镜像地址
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        
        maven { url "https://storage.googleapis.com/download.flutter.io" }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
    	//替换为阿里镜像地址
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        
        maven { url "https://storage.googleapis.com/download.flutter.io" }
    }
}

2、flutter-安卓端运行Could not resolve all artifacts for configuration ‘classpath’

Finished with error: Please review your Gradle project setup in the android/ folder.
* Error running Gradle:
ProcessException: Process "/Users/../Desktop/flutter_app/android/gradlew" exited abnormally:
Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/../Desktop/flutter_app/android/app/build.gradle' line: 25

* What went wrong:
A problem occurred evaluating project ':app'.
> Could not resolve all artifacts for configuration 'classpath'.
   > Could not find lint-gradle-api.jar (com.android.tools.lint:lint-gradle-api:26.1.2).
     Searched in the following locations:
         https://jcenter.bintray.com/com/android/tools/lint/lint-gradle-api/26.1.2/lint-gradle-api-26.1.2.jar

* 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 0s
  Command: /Users/../Desktop/flutter_app/android/gradlew app:properties`

解决方法:
找到放置flutter sdk的目录,打开flutter->packages->flutter_tools->gradle->flutter.gradle
修改内容

buildscript {
    repositories {
        google()
        mavenCentral()  //补充一行
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值