Since yesterday, the Flutter project stopped building for me.
It gives me this error
Running "flutter pub get" in promotyflutter...
Launching lib/main_prod.dart on Redmi Note 8 in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all dependencies for configuration ':app:debugCompileClasspath'.
> Problems reading data from Binary store in /tmp/gradle5564899897575971656.bin offset 447048 exists? true
* 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 29s
Exception: Gradle task assembleDebug failed with exit code 1
I have tried many things but nothing has worked so far:
flutter clean, deleted pubspec.lock and flutter pub cache repair to get rid of cache and reinstall packages but no luck :(
Flutter downgrade, got the same error
Fresh reinstall of flutter, same thing
Fresh git clone of the project and tried running from the prod branch but, nope.
Tried putting org.gradle.parallel=false in gradle settings. No luck :(
I hadn't faced such issues before. In the rare case, flutter clean used to do the trick. Any ideas?
This is the output of flutter doctor -v
[✓] Flutter (Channel stable, 2.2.1, on Linux, locale en_US.UTF-8)
• Flutter version 2.2.1 at /home/bipin/snap/flutter/common/flutter
• Framework revision 02c026b03c (6 weeks ago), 2021-05-27 12:24:44 -0700
• Engine revision 0fdb562ac8
• Dart version 2.13.1
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /home/bipin/Android/Sdk
• Platform android-30, build-tools 30.0.3
• ANDROID_SDK_ROOT = /home/bipin/Android/Sdk
• Java binary at: /opt/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
• All Android licenses accepted.
[✓] Chrome - develop for the web
• Chrome at google-chrome
[✓] Android Studio (version 4.1)
• Android Studio at /opt/android-studio
• Flutter plugin version 57.0.1
• Dart plugin version 201.9380
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
[✓] IntelliJ IDEA Ultimate Edition (version 2020.3)
• IntelliJ at /opt/idea-IU-203.7717.56
• 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
[✓] VS Code (version 1.57.1)
• VS Code at /usr/share/code
• Flutter extension can be installed from:
🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (2 available)
• Redmi Note 8 (mobile) • 169612f4 • android-arm64 • Android 10 (API 29)
• Chrome (web) • chrome • web-javascript • Google Chrome 91.0.4472.114
• No issues found!
This thing worked for me!.
distributionUrl=https://services.gradle.org/distributions/gradle-6.7-all.zip
Related
I recently upgraded Flutter from 2.2.x to 2.10.x.
All was working fine on 2.2.x. On the new version, iOS works properly, but Android is having issues, as it seems to be running the app build.gradle twice: a first time with the proper flavour, a second time with no flavour.
The command is flutter run --flavor dev
The error I get is:
Launching lib/main.dart on sdk gphone x86 arm in debug mode...
lib/main.dart:1
Reading env from: .env.dev
Starting a Gradle Daemon, 1 busy and 8 stopped Daemons could not be reused, use --status for details
> Configure project :app
Reading env from: .env
**************************
*** Missing .env file ****
**************************
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.6.2/userguide/command_line_interface.html#sec:command_line_warnings
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/guillaumeferron/Sites/TendoPay-App/android/app/build.gradle' line: 26
* What went wrong:
A problem occurred evaluating project ':app'.
> Cannot invoke method split() on null object
As you can see, there is a double "Reading env from", which should not happen. The first run works fine and goes through, but gets killed by the second run that fails.
The faulty line (which is not the issue itself, but a consequence of the dual run) is:
def flutterVersionCode = Double.parseDouble(project.env.get("APP_VERSION_ANDROID").split("\\.")[0]) * 10000 + Double.parseDouble(project.env.get("APP_VERSION_ANDROID").split("\\.")[1]) * 100 + Double.parseDouble(project.env.get("APP_VERSION_ANDROID").split("\\.")[2])
My flutter doctor is:
[✓] Flutter (Channel stable, 2.10.3, on macOS 12.2.1 21D62 darwin-x64, locale en-CA)
• Flutter version 2.10.3 at /Users/guillaumeferron/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 7e9793dee1 (3 weeks ago), 2022-03-02 11:23:12 -0600
• Engine revision bd539267b4
• Dart version 2.16.1
• DevTools version 2.9.2
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at /Users/guillaumeferron/Library/Android/sdk
• Platform android-31, build-tools 30.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
• 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-b3-6915495)
[✓] IntelliJ IDEA Ultimate Edition (version 2021.2.2)
• IntelliJ at /Applications/IntelliJ IDEA.app
• Flutter plugin version 60.1.4
• Dart plugin version 212.5284.31
[✓] VS Code (version 1.65.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.36.0
[✓] Connected device (2 available)
• sdk gphone x86 arm (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 99.0.4844.51
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
I've been looking around for a couple hours now, to no avail.
Flutter 2.10.x is not the problem itself, it is Android SDK 31 that is. Indeed, this only happens when I change the SDK version, unfortunately it is a required change in order to support the pub packages versions for 2.10.x.
If I println the different env variables I would get when having it as APP_VERSION_ANDROID="0.2.3" for instance, would be the first occurrence "0.2.3", and null the second, which triggers the error.
I have done all the flutter clean, flutter pub get, flutter pub upgrade, gradle clean, etc..
Any help would be appreciated, as I did not find anything relevant online, and lack the Android dev expertise to debug it myself.
Note: the flavour infrastructure I went for is https://medium.com/#animeshjain/build-flavors-in-flutter-android-and-ios-with-different-firebase-projects-per-flavor-27c5c5dac10b
For anyone stumbling upon this, after many hours of testing and research, what fixed it was to properly upgrade the Android version. So make sure that:
You open the project with Android Studio, and have all proper grade versions downloaded by going to File > Project Structure. Gradle should be v6.1.1 and Plugin v4.0.1
Set your kotlin version to v1.5.31 (https://docs.flutter.dev/release/breaking-changes/kotlin-version)
Have both your target and compile sdk version to 31
This should then work properly, and the gradle won't be executed a second time with no flavor.
I am experiencing issues building an android application on flutter. The IOS app complies with no problems.
The issue seems to be along the lines of Gradle versioning for the flutter's plugin. However, the plugin itself shouldn't be a problem because (I) I can import it in an empty project without issues, (II) if I remove it, then something else fails along the similar lines.
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/rsirokov/.pub-cache/hosted/pub.dartlang.org/devicelocale-0.3.1/android/build.gradle' line: 22
* What went wrong:
A problem occurred evaluating root project 'devicelocale'.
> Failed to apply plugin [id 'com.android.internal.version-check']
> Minimum supported Gradle version is 5.6.4. Current version is 5.6.2. If using the gradle wrapper, try editing the distributionUrl in /Users/rsirokov/.pub-cache/hosted/pub.dartlang.org/devicelocale-0.3.1/android/gradle/wrapper/gradle-wrapper.properties to gradle-5.6.4-all.zip
* 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 6s
Exception: The plugin devicelocale could not be built due to the issue above.
Tried:
flutter pub cache repair;
flutter pub upgrade;
Different versions of Gradle for the main project;
Switched to Flutter stable channel of 1.17.4;
The aforementioned log proposes a solution to switch Gradle version in the plugin's project directory. However, I don't think this would be a good idea since this directory, .pub-cache, is handled automatically by package manager and any manual changes could only make it worse.
[✓] Flutter (Channel stable, v1.17.4, on Mac OS X 10.15.4 19E287, locale en-NO)
• Flutter version 1.17.4 at /Users/rsirokov/Projects/Plugins/flutter
• Framework revision 1ad9baa8b9 (3 weeks ago), 2020-06-17 14:41:16 -0700
• Engine revision ee76268252
• Dart version 2.8.4
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/rsirokov/Library/Android/sdk
• Platform android-30, build-tools 29.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.5, Build version 11E608c
• CocoaPods version 1.9.3
[✓] Android Studio (version 4.0)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 47.1.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
[✓] IntelliJ IDEA Ultimate Edition (version 2019.1.3)
• IntelliJ at /Applications/IntelliJ IDEA.app
• Flutter plugin version 39.0.3
• Dart plugin version 191.8423
[✓] Connected device (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)
• No issues found!
The issue was indeed in the package, but not in the one Flutter was complaining about, not in devicelocale. The problem was in flutter_statusbar_manager. It is not natively migrated to AndroidX (and seems it won't be ever; the package is abandoned, so get rid of it if you're still using it). I actually saw in the logs automatic attempt to migrate it but didn't pay attention to it. It didn't throw any errors, so thought it was migrated successfully.
For more, I have a conversation in the flutter's repo HERE. The problem is that: (I) automatic AndroidX migration of the package by flutter has failed without throwing an error (?), (II) flutter provided misleading error saying that the problem is in the different package.
whenever I try to run in on an Emulator or on a real device, it get stuck at “Running Gradle task 'assembleDebug” and the entire computer just freezes and get stuck, and the only way out is to hard reboot it.
I'm using an Asus laptop ( windows 10 ), with 16GB ram.
flutter --version gives: (when I try flutter upgrade it gives same result and says I have the latest version)
Flutter 1.20.0-1.0.pre.42 • channel master • https://github.com/flutter/flutter.git
Framework • revision 401690a64f (2 days ago) • 2020-06-12 19:45:48 -0700
Engine • revision 965fbbed17
Tools • Dart 2.9.0 (build 2.9.0-14.0.dev 2b917f5b6a)
when I run flutter doctor I get this output in the terminal: UPDATED
C:\Users\Lidor>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, 1.20.0-1.0.pre.42, on Microsoft Windows [Version 10.0.18362.900], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[√] Android Studio (version 4.0)
[√] IntelliJ IDEA Community Edition (version 2019.2)
[!] Connected device
! No devices available
! Doctor found issues in 1 category.
when I run flutter doctor -v I get this output:
C:\Users\Lidor>flutter doctor -v
[√] Flutter (Channel master, 1.20.0-1.0.pre.42, on Microsoft Windows [Version 10.0.18362.900], locale en-US)
• Flutter version 1.20.0-1.0.pre.42 at D:\Study\P.Languages\Flutter\flutter_windows_v1.7.8+hotfix.4-stable\flutter
• Framework revision 401690a64f (2 days ago), 2020-06-12 19:45:48 -0700
• Engine revision 965fbbed17
• Dart version 2.9.0 (build 2.9.0-14.0.dev 2b917f5b6a)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at D:\Lidor\AppData\Local\Android\sdk
• Platform android-29, build-tools 29.0.2
• Java binary at: D:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
X Android license status unknown.
Try re-installing or updating your Android SDK Manager.
See https://developer.android.com/studio/#downloads or visit
https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions.
[√] Android Studio (version 4.0)
• Android Studio at D:\Program Files\Android\Android Studio
• Flutter plugin version 46.0.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] IntelliJ IDEA Community Edition (version 2019.2)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.2
• Flutter plugin version 38.1.4
• Dart plugin version 192.5728.98
[!] Connected device
! No devices available
! Doctor found issues in 2 categories.
I also tried to run flutter channel master as it suggested here and also everything here
There are lots of reasons why it's happening: Did not accept android-licenses, incompatible version of sdk/flutter, Windows Firewall etc.
If you haven't tried:
Updated file android/app/build.gradle with
compileSdkVersion 29
Run:
flutter clean
Otherwise check Flutter App stuck at "Running Gradle task 'assembleDebug'... "
Or if your Android license status unknown.
Android Studio installs without sdkmanager
Uncheck Hide Obsolete Packages and you'll see Android SDK Tools (Obsolete) 26.1.1.
and then flutter doctor --android-licenses
in my case I just run flutter upgrade
everyone.
I've installed the Flutter and I got a problem when I launch a simple application on my device.
I did from the Visual Studio Code, but didn't work. So I executed from the command line with flutter run and also didn't work. There is the output:
Launching lib/main.dart on XT1069 in debug mode...
Initializing gradle... 6.2s
Resolving dependencies... 4.5s
Gradle task 'assembleDebug'...
Gradle task 'assembleDebug'... Done 11.6s
Built build/app/outputs/apk/debug/app-debug.apk.
Installing build/app/outputs/apk/app.apk... 5.0s
Error: ADB exited with exit code 1
Error launching application on XT1069.
I also tried the command flutter clean before run. No success.
The flutter doctor full log:
[✓] Flutter (Channel beta, v0.9.4, on Linux, locale en_US.UTF-8)
• Flutter version 0.9.4 at /home/valdinei/dev/flutter
• Framework revision f37c235c32 (4 weeks ago), 2018-09-25 17:45:40 -0400
• Engine revision 74625aed32
• Dart version 2.1.0-dev.5.0.flutter-a2eb050044
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
• Android SDK at /home/valdinei/Android/Sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• Java binary at: /home/valdinei/dev/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
• All Android licenses accepted.
[✓] Android Studio (version 3.2)
• Android Studio at /home/valdinei/dev/android-studio
• Flutter plugin version 29.1.1
• Dart plugin version 181.5656
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
[✓] VS Code (version 1.28.2)
• VS Code at /usr/share/code
• Flutter extension version 2.19.0
[✓] Connected devices (1 available)
• XT1069 • 0013848438 • android-arm • Android 6.0 (API 23)
• No issues found!
PS: My device is already on debug mode and the screen even "wake up" when I try the command to run.
My application is the default that came when I created the project.
OS: Linux Mint 18.3
I hope you can help me. Thanks!
I'm following to this tutorial:
https://github.com/fablue/building-a-social-network-with-flutter
and I completely copied and pasted the "Resume" section, but it stops with these errors.
Error reading dependency file C:\Users\ritar\AndroidStudioProjects\practice_google_plus\build\app\intermediates\flutter\debug\snapshot_blob.bin.d: java.lang.ArrayIndexOutOfBoundsException: 1
Error reading dependency file C:\Users\ritar\AndroidStudioProjects\practice_google_plus\build\app\intermediates\flutter\debug\snapshot_blob.bin.d: java.lang.ArrayIndexOutOfBoundsException: 1
Error reading dependency file C:\Users\ritar\AndroidStudioProjects\practice_google_plus\build\app\intermediates\flutter\debug\snapshot_blob.bin.d: java.lang.ArrayIndexOutOfBoundsException: 1
Oops; flutter has exited unexpectedly.
Crash report written to C:\Users\ritar\AndroidStudioProjects\practice_google_plus\flutter_08.log;
please let us know at https://github.com/flutter/flutter/issues.
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Program Files\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 435
* What went wrong:
Execution failed for task ':app:flutterBuildDebug'.
> Process 'command 'C:\Program Files\flutter\bin\flutter.bat'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 5s
Finished with error: Gradle build failed: 1
flutter doctor:
[√] Flutter (Channel beta, v0.4.4, on Microsoft Windows [Version 10.0.17134.112], locale en-GB)
• Flutter version 0.4.4 at C:\Program Files\flutter
• Framework revision f9bb4289e9 (6 weeks ago), 2018-05-11 21:44:54 -0700
• Engine revision 06afdfe54e
• Dart version 2.0.0-dev.54.0.flutter-46ab040e58
[√] Android toolchain - develop for Android devices (Android SDK 27.0.3)
• Android SDK at C:\Users\ritar\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-27, build-tools 27.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
• All Android licenses accepted.
[√] Android Studio (version 3.1)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 24.1.1
• Dart plugin version 173.4700
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
[√] Connected devices (1 available)
• 601SO • CB512BVV00 • android-arm64 • Android 7.0 (API 24)
I'm glad if you can tell me how to make it work.
This package is not maintained anymore and outdated. It was developed for the early flutter and does not use Dart 2. Also the Readme says:
This project tutorial is OUT OF DATE. It was created with a very early version of flutter and I am not able to maintain it
Here is an issue that describes your problem.
Seems this problem is related with /build directory. Run:
flutter clean //removes your /build directory
flutter run
As documented in this issue