flutter Required by: project :app > project :XXXX

最近在flutter项目上突然遇到了此类问题(之前都是好好的):

//XXX 是代表某一个第三方库
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.删除项目里Android目录下.gradle文件夹,然后clean,重新编译

  • 但是以上方法都无效,之后索性删除了错误信息里提到的插件(比如:shared_preferences)就好了

找到你的flutter的目录,然后找到.pub-cache/hosted/pub.flutter-io.cn的目录,把目录里面所有xxx_web和xxx_macos的文件夹删除掉,然后直接运行你的flutter项目即可。

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容