LoginSignup
4
4

More than 5 years have passed since last update.

Android StudioでFlutterアプリを起動すると Could not find lint-gradle-api.jar (com.android.tools.lint:lint-gradle-api:26.1.2)

Posted at

環境

  • Android Studio 3.2.1
  • Flutter 0.9.4

現象

Android StudioでFlutterアプリを新規作成して起動したところ Could not find lint-gradle-api.jar (com.android.tools.lint:lint-gradle-api:26.1.2) といったエラーが発生した:thinking:

実行ログ

Launching lib/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
* Error running Gradle:
Exit code 1 from: /Users/mouchi717/Projects/flutter_app_intro/android/gradlew 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 '/Users/mouchi717/Projects/flutter_app_intro/android/app/build.gradle' line: 26

* 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 3s

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

原因

Flutterのbuild.gradleにある依存関係の宣言順の問題。
公式のIssueでも既に解決されていた。
https://github.com/flutter/flutter/issues/23459

要するにjcenter()よりgoogle()を先に宣言する必要があるらしい。

解決方法

flutter.gradleの下記コードをjcenter()の上に移動するだけ。

maven {
    url 'https://dl.google.com/dl/android/maven2'
} 

修正後はこんな感じになる。

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

再度、起動してみるとうまくいった!:sun_with_face:

実行ログ

Launching lib/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
timeout waiting for the application to start
Gradle task 'assembleDebug'...
Built build/app/outputs/apk/debug/app-debug.apk.
Installing build/app/outputs/apk/app.apk...
Syncing files to device Android SDK built for x86...
D/        ( 4302): HostConnection::get() New Host Connection established 0xdd6a9100, tid 4338
D/EGL_emulation( 4302): eglMakeCurrent: 0xcb9414e0: ver 3 0 (tinfo 0xcb94f240)
I/Choreographer( 4302): Skipped 44 frames!  The application may be doing too much work on its main thread.

実行結果

スクリーンショット 2018-11-04 12.02.40.png

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4