このプロジェクトはフラッターしかし、Gradle のバージョンが原因で、数週間にわたって apk をビルドできませんでした。あらゆることを試しましたが、Flutter は常に以下のエラーを返します。
Gradle バージョンが 4.10.2 と表示されているにもかかわらず、見つかったすべてのアップデートをすでにインストールしています。
- フラッタービルドapk
...
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\israel.gomes\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\audioplayers-0.17.4\android\build.gradle' line: 25
* What went wrong:
A problem occurred evaluating root project 'audioplayers'.
> Failed to apply plugin [id 'kotlin-android']
> The current Gradle version 4.10.2 is not compatible with the Kotlin Gradle plugin. Please use Gradle 5.3 or newer, or the previous version of the Kotlin plugin.
* 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 1s
The plugin audioplayers could not be built due to the issue above.
プロジェクトのステータスと環境に関する情報はこちら----------------------
- すでに変更済みgradle-wrapper.properties(現行ファイル):
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip
- android/ビルド.gradle(現行ファイル):
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
.
.
.
- gradle --バージョン
------------------------------------------------------------
Gradle 5.6.2
------------------------------------------------------------
Build time: 2019-09-05 16:13:54 UTC
Revision: 55a5e53d855db8fc7b0e494412fc624051a8e781
Kotlin: 1.3.41
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.14 compiled on March 12 2019
JVM: 1.8.0_261 (Oracle Corporation 25.261-b12)
OS: Windows 10 10.0 amd64
- フラッタードクター -v
[√] Flutter (Channel dev, 2.1.0-12.1.pre, on Microsoft Windows [versão 10.0.19042.867], locale pt-BR)
• Flutter version 2.1.0-12.1.pre at C:\Flutter
• Framework revision 8264cb3e8a (3 weeks ago), 2021-03-10 12:37:57 -0800
• Engine revision 711ab3fda0
• Dart version 2.13.0 (build 2.13.0-116.0.dev)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at C:\Users\israel.gomes\AppData\Local\Android\Sdk
• Platform android-30, build-tools 30.0.2
• ANDROID_HOME = C:\Users\israel.gomes\AppData\Local\Android\Sdk
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[√] Android Studio (version 4.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] IntelliJ IDEA Community Edition (version 2020.3)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.2.3
• Flutter plugin version 55.0.4
• Dart plugin version 203.7759
[√] VS Code (version 1.54.3)
• VS Code at C:\Users\israel.gomes\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.20.0
[√] Connected device (3 available)
• Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 7.1.1 (API 25) (emulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 89.0.4389.114
• Edge (web) • edge • web-javascript • Microsoft Edge 87.0.664.75
• No issues found!
ベストアンサー1
以前の Flutter プロジェクトで Gradle をアップグレードした方法は次のとおりです。
最新バージョンの Flutter を使用して新しい一時プロジェクトを作成します。これを使用して、現在 Flutter が使用している Gradle のバージョンを確認します。
一時プロジェクトを開くandroid/ビルド.gradle使用されている Gradle のクラスパス バージョンを確認し、古い Flutter プロジェクトでそれを更新します。今日の私の場合は次のようになります。
classpath 'com.android.tools.build:gradle:4.1.0'
一時プロジェクトを開くandroid/gradle/ラッパー/gradle-wrapper.propertiesをチェックします
distributionUrl
。古いプロジェクトを更新して同じものを使用します。私の場合は、今日は次のようになります。distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
アプリを再実行します。新しいバージョンの gradle をディレクトリにダウンロードする必要がある
android/.gradle
ため、初回は時間がかかる場合があります。
または...
Android プロジェクトに多くのカスタマイズがない場合は、android
フォルダーを削除し (最初に、特に key.properties ファイルをバックアップしてください)、プロジェクトのルートから次のコマンドを実行して再作成します。
flutter create .
これは最近の私の好みです。 でランチャーアイコンやその他のカスタム設定を再作成する必要がありますがAndroidManifest.xml
、Flutter が Android に提供する最新のアップデートを取得していることはわかっています。プロジェクトが 1 年か 2 年前のものであれば、Flutter が Android に関して変更する内容は Gradle よりもずっと多いようです。