3

刚建好一个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'
    }
}
至此从新运行,解决掉问题。
myxingke 285
2018-10-23 提问

查看全部 7 个回答

1

解决方法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'
}

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

1

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

哀而不傷 · 2018年11月10日

展开评论

推广链接