初学flutter 刚折腾完环境遇上如下问题,* Error running Gradle: 不知道如何下手寻找!

刚建好一个demo 编译运行一个demo 控制台就出现如下情况

Launching lib/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
* Error running Gradle:
ProcessException: Process "/Users/rabbit/develop/android/flutter_app/android/gradlew" 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:
Build file '/Users/rabbit/develop/android/flutter_app/android/app/build.gradle' line: 25

* What went wrong:
A problem occurred evaluating project ':app'.
> Could not resolve all files for configuration 'classpath'.
   > Could not find lint-gradle-api.jar (com.android.tools.lint:lint-gradle-api:26.1.2).
     Searched in the following locations:
         https://jcenter.bintray.com/com/android/tools/lint/lint-gradle-api/26.1.2/lint-gradle-api-26.1.2.jar

* 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 0s
  Command: /Users/rabbit/develop/android/flutter_app/android/gradlew app:properties

Finished with error: Please review your Gradle project setup in the android/ folder.

网上找了也没有遇上合适的答案来解决它,我看到提示未找到 com.android.tools.lint:lint-gradle-api:26.1.2 但根据提示地址打开无法下载,如果能下载下来应该放在什么位置呢!

已解决:

解决方法1:修改build.gradle,注释掉jcenter(),google()。使用阿里的镜像。原因是jcenter google库无法访问到导致的问题。虽然我有万能的爬墙工具,开启全局代理依然被我们伟大的发改委墙掉了!

buildscript {
    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' }
    }

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

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' }
    }
}


第二步:找到fluttersdk目录 进入如下目录

Macintosh HD⁩ ▸ ⁨用户⁩ ▸ ⁨rabbit⁩ ▸ ⁨资源库⁩ ▸ ⁨Flutter⁩ ▸ ⁨packages⁩ ▸ ⁨flutter_tools⁩ ▸ ⁨gradle⁩
找到下 flutter.gradle文件 找如如下内容替换成和我一样的 把jcenter注释掉。

​buildscript {
    repositories {
        //jcenter()
        //maven {
        //    url 'https://dl.google.com/dl/android/maven2'
        //}
        maven{
            url 'https://maven.aliyun.com/repository/jcenter'
        }
        maven{
            url 'http://maven.aliyun.com/nexus/content/groups/public'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
    }
}
至此从新运行,解决掉问题。
阅读 32k
8 个回答

解决方法1:修改build.gradle,注释掉jcenter(),google()。使用阿里的镜像。原因是jcenter google库无法访问到导致的问题。虽然我有万能的爬墙工具,开启全局代理依然被我们伟大的发改委墙掉了!

buildscript {

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' }
}

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

}

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' }
}

}

第二步:找到fluttersdk目录 进入如下目录

Macintosh HD⁩ ▸ ⁨用户⁩ ▸ ⁨rabbit⁩ ▸ ⁨资源库⁩ ▸ ⁨Flutter⁩ ▸ ⁨packages⁩ ▸ ⁨flutter_tools⁩ ▸ ⁨gradle⁩
找到下 flutter.gradle文件 找如如下内容替换成和我一样的 把jcenter注释掉。

​buildscript {

repositories {
    //jcenter()
    //maven {
    //    url 'https://dl.google.com/dl/android/maven2'
    //}
    maven{
        url 'https://maven.aliyun.com/repository/jcenter'
    }
    maven{
        url 'http://maven.aliyun.com/nexus/content/groups/public'
    }
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.2'
}

}
至此从新运行,解决掉问题。

新手上路,请多包涵

楼上遗漏了一条,flutter.gradle还需要加上这段代码:

maven{
    url 'https://maven.aliyun.com/repository/google'
}

尝试在每个project的build.gradle文件下引入google()

allprojects {
    repositories {
        // google() 要放在第一个加载
        google()
        jcenter()
    }
}
新手上路,请多包涵

请问楼主解决了么??我也遇到此问题,而且未找到解决方案,估计是android studio 版本与gradle版本的问题

我已经改了build.gradle和flutter.gradle文件,点运行还是一直
Initializing gradle...
timeout waiting for the application to start
怎么办。。

翻墙,解决一切痛点

新手上路,请多包涵

之前我在pc端又是翻墙,又是各种配置,然而还是不行,后来我用pc连接手机热点,在pc上翻墙居然可以了,我感觉还是网络得问题,pc端网络和移动端网络不一样,移动端就ok,大家可以试试

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