Flutter报错:Could not resolve io.flutter:flutter_embedding_debug:1.0.0
问题
在编译Flutter项目的时候出现问题:
- **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 4s
Finished with error: Gradle task assembleDebug failed with exit code 1**
原因
网络问题
从上面黑体字标注的结果来看:无法获得从https://jcenter.bintray.com/io/flutter/flutter_embedding_debug/ 获得到io.flutter:flutter_embedding_debug:1.0.0
并且进入该页面也无效(魔法也无效访问)
解决
进入android/build.gradle:
在repositories添加新的源:(阿里云),并且ban掉Google和jcenter源
//google()
//jcenter()
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' }
maven { url "http://download.flutter.io" }
PS:也可以添加其他源如清华,中科大等
如图:
示例代码如下:
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
//google()
//jcenter()
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' }
maven { url "http://download.flutter.io" }
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
}
}
allprojects {
repositories {
//google()
//jcenter()
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' }
maven { url "http://download.flutter.io" }
}
}