最近在flutter項(xiàng)目上突然遇到了此類問題(之前都是好好的):
//XXX 是代表某一個(gè)第三方庫
Could not resolve all task dependencies for configuration ‘:XXX:debugCompileClasspath’.
Could not resolve project :XXX_macos.
Required by:
project :XXX
Unable to find a matching configuration of project :XXX_macos:
- None of the consumable configurations have attributes.
Could not resolve project :XXX_web.
Required by:
project :XXX
Unable to find a matching configuration of project :XXX_web:
- None of the consumable configurations have attributes.
查找了很多資料,主要有以下幾種方案:
1.flutter clean之后重新rebuild
2.修改鏡像:
buildscript {
ext.kotlin_version = '1.3.50'
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' }
mavenLocal()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$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' }
mavenLocal()
mavenCentral()
}
3.修改配置為:
url "http://download.flutter.io"
4.刪除項(xiàng)目里Android目錄下.gradle文件夾押框,然后clean叶圃,重新編譯
- 但是以上方法都無效吱韭,之后索性刪除了錯(cuò)誤信息里提到的插件(比如:shared_preferences)就好了
找到你的flutter的目錄愈捅,然后找到.pub-cache/hosted/pub.flutter-io.cn的目錄拯刁,把目錄里面所有xxx_web和xxx_macos的文件夾刪除掉谍咆,然后直接運(yùn)行你的flutter項(xiàng)目即可窃肠。