0

I am trying run flutter app via Android Studio 3.2 but not working.

I tried too many ideas and solutions but still not working.

Linux Ubuntu 18.04

flutter doctor
[✓] Flutter (Channel beta, v0.9.4, on Linux, locale cs_CZ.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
[✓] Android Studio (version 3.2)
[✓] Connected devices (1 available)

• No issues found!

Error:

Launching lib/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
Finished with error: Please review your Gradle project setup in the android/ folder.
* Error running Gradle:
Exit code 1 from: /media/hdd/Projects/apps/flutter_app_new/android/gradlew app:properties:
Starting a Gradle Daemon, 1 busy Daemon could not be reused, use --status for details

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 '/media/hdd/Projects/apps/flutter_app_new/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 9s

I installed gradle via apt install gradle and run gradle --stacktrace

gradle --stacktrace
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.gradle.internal.reflect.JavaMethod (file:/usr/share/gradle/lib/gradle-base-services-3.4.1.jar) to method java.lang.ClassLoader.getPackages()
WARNING: Please consider reporting this to the maintainers of org.gradle.internal.reflect.JavaMethod
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Starting a Gradle Daemon (subsequent builds will be faster)
:help

Welcome to Gradle 3.4.1.

To run a build, run gradle <task> ...

To see a list of available tasks, run gradle tasks

To see a list of command-line options, run gradle --help

To see more detail about a task, run gradle help --task <task>

BUILD SUCCESSFUL

I tried change version of gradle in gradle-wrapper.properties from

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

to

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

gradle.build

{
buildscript {
    repositories {
        google()
        jcenter()
    }

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

allprojects {
    repositories {
        google()
        jcenter()
    }
}

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

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

} 

But still not working. Please help. Thnak you.

Petr Klein
  • 797
  • 2
  • 9
  • 23

2 Answers2

0

I don'to know why but in app/build.gradle at line 25 I have

apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

So I had to change file in flutter library! in file flutter.gradle I had

buildscript {
    repositories {
        jcenter() 
        maven {
            url 'https://dl.google.com/dl/android/maven2'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
    }
}

change to this

buildscript {
    repositories {
        maven {
            url 'https://dl.google.com/dl/android/maven2'
        }
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
    }
}

So I dont know why I have to changing library files. Do you know why? Thank you

Petr Klein
  • 797
  • 2
  • 9
  • 23
0

Basically it's a problem with flutter, but the root cause is not flutter. Check this answer, you can easily make it work by switch to the master channel.

Feu
  • 5,372
  • 1
  • 31
  • 57