由于国内 网络环境原因, 新建 flutter工程的 配置文件 需要修改几个地方,
1. gradle-wrapper.properties
问题:Exception in thread "main" java.net.ConnectException: Connection timed out: connect:
解决方法:修改为 国内镜像
distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-7.6.3-all.zip
2. build.gradle
问题:Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath'.
或者:
Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository 'maven(XXX)' to redirect to a secure protocol (like HTTPS) or allow insecure protocols.
解决方法:修改为 国内镜像,并且配置信 任该镜像
allprojects {repositories { // google() // mavenCentral()maven {allowInsecureProtocol = trueurl 'https://mirrors.cloud.tencent.com/gradle/'}maven {allowInsecureProtocol = trueurl 'https://mirrors.cloud.tencent.com/nexus/repository/maven-public/'}maven {allowInsecureProtocol = trueurl 'https://maven.aliyun.com/repository/gradle-plugin' }maven {allowInsecureProtocol = trueurl 'http://maven.aliyun.com/nexus/content/groups/public' }maven {allowInsecureProtocol = trueurl 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }maven {allowInsecureProtocol = trueurl 'https://maven.aliyun.com/repository/jcenter' }maven {allowInsecureProtocol = trueurl 'https://maven.aliyun.com/repository/google' }} }