flutter问题,Could not find method maven() for arguments 的错误

先贴配置,build.gradle

buildscript {
    repositories {
        google()
        jcenter()
        mavenCentral()
       maven { url 'https://maven.google.com' }
        //mavenCentral()
     //   maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/' }
    //    maven{ url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'}
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
    }
}

allprojects {
    repositories {
      //  maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
       // maven{ url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'}
        mavenCentral()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

运行flutter run之后,报错如下

Launching lib/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...                                       0.9s
Resolving dependencies...
* Error running Gradle:
ProcessException: Process "D:\flutterproject\tk\android\gradlew.bat" 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:
Script 'D:\flutter\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 27

* What went wrong:
A problem occurred evaluating script.
> Could not find method maven() for arguments [flutter_70fv7lssvws82r3weljr8tpe1$_run_closure1$_closure4@6a83feb5] on object of
type org.gradle.api.internal.initialization.DefaultScriptHandler.

* 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 1s
  Command: D:\flutterproject\tk\android\gradlew.bat app:properties


Please review your Gradle project setup in the android/ folder.

请问有人遇到过吗?查好久没找到答案。希望有大神帮忙解决下,谢谢谢谢

阅读 10.4k
3 个回答

相关链接

这个原因,应该是墙的原因。因为墙在,所以下载不了相关文件,建议换成阿里源。

我看你也换过阿里源,代码里有注释,估计可能失败过。我猜阿里源失败的原因应该是你配置过代理。

如果配置过代理,即使改成阿里源也是会报错的。所以你要先去掉代理。

我之前配置环境的时候也碰到了这个问题,所以记成了上述链接里的文章,希望对你有用。

解决了吗?我在集成barcode_scan 的时候遇到了同样的问题

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏