Problem with the Gradle when running the project on flutter in Android Studio

0

I just started a flutter project with the Android Studio, and as basic as it was to run, to run it in the Genymotion emulator. When trying to run it, an error occurs. I have everything installed, and restart the programs and the " Flutter doctor " does not throw any errors

The error:

Launching lib\main.dart on Google Nexus 6, 8 0, API 26, 1440x2560 in debug mode...
Initializing gradle...
Resolving dependencies...
* Error running Gradle:
Exit code 1 from: C:\Users\Tomas\AndroidStudioProjects\mi_app\android\gradlew.bat app:properties:
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 'C:\Users\Tomas\AndroidStudioProjects\mi_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 2s

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

I already modified the file but it did not appear in $ flutterRoot (There were no folders with that name), but the file name was the same and I just added google (), which is now this:

Launching lib \ main.dart on Google Nexus 6, 8 0, API 26, 1440x2560 in debug mode ... Initializing gradle ... Resolving dependencies ... timeout waiting for the application to start

asked by tomascormack 25.10.2018 в 16:30
source

2 answers

0

That error is because you are not being detected by the google library in this section:

buildscript {
    repositories {
        google()
        jcenter()
        maven {
            url 'https://dl.google.com/dl/android/maven2'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
    }
}
    
answered by 25.10.2018 в 22:13
0

It is an error with the latest version of Flutter, however, they already sent the PR and it is already deployed in the channel master, I have no idea when it will be in dev / beta.

If you do not want to wait, you can fix it in the following way:

Locate the gradle-wrapper.properties file inside android / gradle and use the following gradle version:

distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip

Then locate the path of your flutter sdk ($ flutterRoot) and edit this file:

$flutterRoot/packages/flutter_tools/gradle/flutter.gradle

Check and change so that you have these repositories and dependencies:

     buildscript {
        repositories {
            google()
            jcenter()
            maven {
                url 'https://dl.google.com/dl/android/maven2'
            }
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.2.1'
        }
    }
    
answered by 26.10.2018 в 07:57