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.
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.
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
I get a build error using flutter version 1.2.2 and map_view version 0.0.14.
I tried to use this code in build.gradle
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.2-4'
I followed all the steps here https://pub.dartlang.org/packages/map_view#-readme-tab-
I have an api-key but get the following build error
Error running Gradle: ProcessException: Process “C:UsersAlmoit PCDesktopMyAppMapflutter_app2androidgradlew.bat” exited
abnormally:
Configure project :map_view
WARNING: The specified Android SDK Build Tools version (27.0.3) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.2.1.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove “buildToolsVersion ‘27.0.3’” from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
FAILURE: Build failed with an exception.
What went wrong: The Android Gradle plugin supports only Kotlin Gradle plugin version 1.2.51 and higher. Project ‘android’ is using
version 1.1.2-4.
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 10s Command: C:UsersAlmoit
PCDesktopMyAppMapflutter_app2androidgradlew.bat app:properties
With flutter doctor, everything seems fine.
flutter doctor -v
[√] Flutter (Channel stable, v1.2.1, on Microsoft Windows [Version 10.0.17763.437], locale en-AI)
• Flutter version 1.2.1 at C:flutter
• Framework revision 8661d8aecd (10 weeks ago), 2019-02-14 19:19:53 -0800
• Engine revision 3757390fa4
• Dart version 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at C:Sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• ANDROID_HOME = C:Sdk
• Java binary at: C:Program FilesAndroidAndroid Studiojrebinjava
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
• All Android licenses accepted.
[√] Android Studio (version 3.3)
• Android Studio at C:Program FilesAndroidAndroid Studio
• Flutter plugin version 33.4.1
• Dart plugin version 182.5215
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
[√] Connected device (1 available)
• SPH L520 • 2d81b4cf • android-arm • Android 4.4.2 (API 19)
• No issues found!
I searched it everywhere but can't find the answer. Please help me regarding this.
In your /android/build.gradle try increasing the version of the kotlin gradle plugin like so:
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.0'
I read somewhere that flutter now only support version 1.3+.
I just tried it and now I can at least build my app for android.
PS: Since you are using an older version of flutter maybe the kotlin plugin will work with an older version as mentioned in the error messages:
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.51'
First sorry for bad English.
I'm starting in Flutter, I already installed everything that is necessary but when trying to run the test app (either in the emulator or the device) I get the error messages below.
Launching lib\main.dart on XT1097 in debug mode...
Initializing gradle...
Resolving dependencies...
* Error running Gradle:
Exit code 1 from: C:\Testes\first_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:\Testes\first_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 3s
Finished with error: Please review your Gradle project setup in the android/ folder.
**************This is the result of my flutter Doctor**************************
[√] Flutter (Channel beta, v0.9.4, on Microsoft Windows [versão 10.0.17134.345], locale pt-BR)
• Flutter version 0.9.4 at C:\Src\flutter
• Framework revision f37c235c32 (5 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.2)
• Android SDK at C:\Users\AKC\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.2
• 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)
X Android license status unknown.
[√] Android Studio (version 3.1)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 29.0.1
• Dart plugin version 173.4700
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
[√] VS Code, 64-bit edition (version 1.27.2)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension version 2.19.0
[√] Connected devices (1 available)
• XT1097 • 0011102704 • android-arm • Android 6.0 (API 23)
! Doctor found issues in 1 category.
I've tried to resolve the android licenses running flutter doctor --android-licenses but the error has returned
Thanks, if anyone can help.
Sorry, a lot of people is experiencing that both to new and old projects (including me).
It's already solved, but it's not yet in the beta channel (which is currently the most stable one).
I suggest you to temporarily switch to the master channel (most recent and least stable), later you can switch back to the beta channel.
As you're new to flutter, I must say that this is uncommon, it's the first time I see a serious problem like that take more than a week to get solved - and as you can see in the issue in the link, the root cause is NOT flutter itself.
list channels and see which one you're using
flutter channel
switch to master and upgrade
flutter channel master
flutter upgrade
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