How to fix 'Error running gradle # line 24' - flutter

Running my first Flutter program, encountered this issue. Unable to resolve it by adding Google().
Error Message
*Error running Gradle:
ProcessException: Process "C:\Users\hariharan\Desktop\helloflutter\android\gradlew.bat" exited abnormally:
FAILURE: Build failed with an exception.
*Where:
Build file 'C:\Users\hariharan\Desktop\helloflutter\android\build.gradle' line: 24
*What went wrong:
A problem occurred evaluating root project 'android'.
A problem occurred configuring project ':app'.
Failed to find target with hash string 'android-28' in: C:\Users\hariharan\AppData\Local\Android\sdk
*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 15s
Command: C:\Users\hariharan\Desktop\helloflutter\android\gradlew.bat app:properties
Please review your Gradle project setup in the android/ folder.
Running flutter doctor -v
[√] Flutter (Channel stable, v1.5.4-hotfix.2, on Microsoft Windows [Version 10.0.17134.829], locale en-SG)
• Flutter version 1.5.4-hotfix.2 at C:\flutter_windows_v1.5.4-hotfix.2-stable\flutter
• Framework revision 7a4c33425d (8 weeks ago), 2019-04-29 11:05:24 -0700
• Engine revision 52c7a1e849
• Dart version 2.3.0 (build 2.3.0-dev.0.5 a1668566e5)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.0)
• Android SDK at C:\Users\hariharan\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.0
• ANDROID_HOME = C:\Users\hariharan\AppData\Local\Android\Sdk
• Java binary at: C:\Program Files\Android\Android Studio1\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
• All Android licenses accepted.
[√] Android Studio (version 3.4)
• Android Studio at C:\Program Files\Android\Android Studio1
• Flutter plugin version 36.1.1
• Dart plugin version 183.6270
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
[√] VS Code (version 1.35.1)
• VS Code at C:\Users\hariharan\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.1.0
[√] Connected device (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)
No issues found!

From the error: Failed to find target with hash string 'android-28', it seems that it's unable to find build tools for version 28. If you're using Android Studio, you can go through Tools > SDK Manager > Android SDK and make sure that you've got your Android SDKs up-to-date.

Related

Flutter application build failed and throwing Fatal Error ( Content is not allowed in prolog.)

I'm facing an issue after run the Flutter Upgrade once again on existing one. When I try to run my app I confronted the error that has given below.
Error
[Fatal Error] x86_debug-1.0.0-bd539267b42051b0da3d16ffa8f48949dce8aa8f.pom:2:1: Content is not allowed in prolog.
[Fatal Error] flutter_embedding_debug-1.0.0-bd539267b42051b0da3d16ffa8f48949dce8aa8f.pom:9:12: An invalid XML character (Unicode: 0x0) was found in the element content of the document.
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Could not resolve io.flutter:x86_debug:1.0.0-bd539267b42051b0da3d16ffa8f48949dce8aa8f.
Required by:
project :app
> Could not resolve io.flutter:x86_debug:1.0.0-bd539267b42051b0da3d16ffa8f48949dce8aa8f.
> Could not parse POM https://storage.googleapis.com/download.flutter.io/io/flutter/x86_debug/1.0.0-bd539267b42051b0da3d16ffa8f48949dce8aa8f/x86_debug-1.0.0-bd539267b42051b0da3d16ffa8f48949dce8aa8f.pom
> Content is not allowed in prolog.
Could not resolve io.flutter:flutter_embedding_debug:1.0.0-bd539267b42051b0da3d16ffa8f48949dce8aa8f.
Required by:
project :app > project :video_player_android
project :app > project :wakelock
> Could not resolve io.flutter:flutter_embedding_debug:1.0.0-bd539267b42051b0da3d16ffa8f48949dce8aa8f.
> Could not parse POM https://storage.googleapis.com/download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-bd539267b42051b0da3d16ffa8f48949dce8aa8f/flutter_embedding_debug-1.0.0-bd539267b42051b0da3d16ffa8f48949dce8aa8f.pom
> An invalid XML character (Unicode: 0x0) was found in the element content of the document.
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 26s
Exception: Gradle task assembleDebug failed with exit code 1
I've tried every possible solution but couldn't find the right one.
Most tried solution
allprojects {
repositories {
......
maven {url "https://storage.googleapis.com/download.flutter.io"}
}
}
Reffernce: enter link description here
Flutter Doctor log
[√] Flutter (Channel stable, 2.10.3, on Microsoft Windows [Version 10.0.19041.1415], locale en-US)
• Flutter version 2.10.3 at C:\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 7e9793dee1 (11 days 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.3)
• Android SDK at C:\Users\User\AppData\Local\Android\Sdk
X cmdline-tools component is missing
Run path/to/sdkmanager --install "cmdline-tools;latest"
See https://developer.android.com/studio/command-line for more details.
X Android license status unknown.
Run flutter doctor --android-licenses to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[X] Visual Studio - develop for Windows
X Visual Studio not installed; this is necessary for Windows development.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 4.1)
• 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)
[√] VS Code (version 1.65.2)
• VS Code at C:\Users\User\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.22.0
[√] Connected device (5 available)
• Redmi Note 8 (mobile) • 13ab130b • android-arm64 • Android 10 (API 29)
• sdk gphone x86 arm (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19041.1415]
• Chrome (web) • chrome • web-javascript • Google Chrome 84.0.4147.125
• Edge (web) • edge • web-javascript • Microsoft Edge 84.0.522.59
[√] HTTP Host Availability
• All required HTTP hosts are available
! Doctor found issues in 2 categories.
Note: Code run perfectly on Web version but issue arise when try to run on Emulator or physical device.
Any suggestion and solution on this issue would be appriciated.
Thanks.

Flutter 2 build project: Error: The method 'SpinKitPouringHourglass' isn't defined for the class '_LoadingIndicatorState'

I am trying to start my project with android studio but an error occurred whereas it was functionnal yesterday.
AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_easyloading-3.0.0/lib/src/widgets/indicator.dart:166:22: Error: The method 'SpinKitPouringHourglass' isn't defined for the class '_LoadingIndicatorState'.
- '_LoadingIndicatorState' is from 'package:flutter_easyloading/src/widgets/indicator.dart' ('/C:/Users/[MYUSER]/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_easyloading-3.0.0/lib/src/widgets/indicator.dart').
Try correcting the name to the name of an existing method, or defining a method named 'SpinKitPouringHourglass'.
_indicator = SpinKitPouringHourglass(
^^^^^^^^^^^^^^^^^^^^^^^
FAILURE: Build failed with an exception.
* Where:
Script 'C:\lib\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1035
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\lib\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. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 11s
Exception: Gradle task assembleDebug failed with exit code 1
What I have already done:
reinstalled flutter SDK
reinstalled Android Studio
flutter clean
remove the build folder
remove the pubseck.lock
flutter pub get
flutter pub upgrade
flutter pub outdated
flutter doctor:
C:\lib\flutter\bin\flutter.bat doctor --verbose
[√] Flutter (Channel stable, 2.2.3, on Microsoft Windows [version 10.0.19042.1165], locale fr-FR)
• Flutter version 2.2.3 at C:\lib\flutter
• Framework revision f4abaa0735 (8 weeks ago), 2021-07-01 12:46:11 -0700
• Engine revision 241c87ad80
• Dart version 2.13.4
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at C:\Users\[MY_USER]\AppData\Local\Android\sdk
• Platform android-30, build-tools 30.0.2
• Java binary at: C:\Program Files\Java\jdk1.8.0_291\bin\java
• Java version Java(TM) SE Runtime Environment (build 1.8.0_291-b10)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[!] Android Studio (version 4.1.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
X Unable to determine bundled Java version.
• Try updating or re-installing Android Studio.
[√] VS Code (version 1.59.1)
• VS Code at C:\Users\[MY_USER]\AppData\Local\Programs\Microsoft VS Code
• Flutter extension can be installed from:
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[√] Connected device (3 available)
• Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 92.0.4515.159
• Edge (web) • edge • web-javascript • Microsoft Edge 92.0.902.84
! Doctor found issues in 1 category.
Process finished with exit code 0
What should I do to fix this error ?
I have the same question too.
flutter_easyloading was working well before.
SO I find "import 'package:flutter_spinkit/flutter_spinkit.dart';" in the indicator.dart in the flutter_easyloading 3.0.0.
BUT the flutter_spinkit has published a new version 5.1.0 and see the ChangeLog, I find the log "Renamed SpinKitPouringHourglass -> SpinKitPouringHourGlass for correctness".
YES, the flutter_easyloading MUST modify too for fixing this bug.
You are using a method that does not exist with a plugin: flutter_easyloading.
Flutter easly loading is the problem.
good evening to you

Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'. These error comes when I run flutter project in emulator

I create a empty flutter application and I got this error when I run this in android emulator. I already installed java, AD (4.1),git but don't know what happens. If anyone has idea let me know. Thanks :)
error log
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Failed to install the following SDK components:
build-tools;28.0.3 Android SDK Build-Tools 28.0.3
platforms;android-29 Android SDK Platform 29
Install the missing components using the SDK manager in Android Studio.
* 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
flutter doctor full summary
PS F:\Flutter\flutter_application_1> flutter doctor -v [√] Flutter (Channel stable, 2.0.0, on Microsoft Windows [Version 10.0.19042.804], locale en-US)
• Flutter version 2.0.0 at C:\src\flutter
• Framework revision 60bd88df91 (16 hours ago), 2021-03-03 09:13:17 -0800
• Engine revision 40441def69
• Dart version 2.12.0
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at C:\Users\vaagm\AppData\Local\Android\sdk
• Platform android-30, build-tools 30.0.3
• 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\Google\Chrome\Application\chrome.exe
[√] Android Studio (version 4.1.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)
[√] VS Code (version 1.53.2)
• VS Code at C:\Users\vaagm\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 5.1.1 (API 22) (emulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 88.0.4324.190
• Edge (web) • edge • web-javascript • Microsoft Edge 88.0.705.81
• No issues found!
The solution is there in the error message.
you need to install following SDK components:
build-tools; 28.0.3 Android SDK Build-Tools 28.0.3
platforms; android-29 Android SDK Platform 29
Install the missing components using the SDK manager in Android Studio.
Go to File>settings>Appearance & Behaviour>System settings>Android SDK> And install the mentioned sdk build tools,platform.
After some searching, according to this question, you need to accept android licenses. Check this out and let us know your results :) Hope it will help

First Flutter gradle build failed (what went wrong:- java/lang/Throwable$WrappedPrintWriter)

I am trying to build first flutter project only and it shows gradle build failed, I don't understand why is this happening I searched a lot and no solution worked for me. I am started working on flutter again after some time.
In flutter doctor everything shows fine, pug get is working.
I did flutter upgrade and then run and still it is not working.
Can somebody help?
FAILURE: Build failed with an exception.
* What went wrong:
java/lang/Throwable$WrappedPrintWriter
* 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
Exception: Gradle task assembleDebug failed with exit code 1
flutter doctor -v
[√] Flutter (Channel stable, 1.22.4, on Microsoft Windows [Version 10.0.18363.1198], locale en-US)
• Flutter version 1.22.4 at D:\flutter
• Framework revision 1aafb3a8b9 (3 weeks ago), 2020-11-13 09:59:28 -0800
• Engine revision 2c956a31c0
• Dart version 2.10.4
• Pub download mirror https://pub.dev
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at D:\Android\SDK
• Platform android-29, build-tools 29.0.3
• ANDROID_HOME = D:\Android\SDK
• Java binary at: D:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
• All Android licenses accepted.
[√] Android Studio (version 3.6)
• Android Studio at D:\Program Files\Android\Android Studio
• Flutter plugin version 48.1.1
• Dart plugin version 192.8052
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
[√] VS Code (version 1.51.1)
• VS Code at C:\Users\vishnu Agarwal\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.16.0
[√] Connected device (1 available)
• SM G770F (mobile) • RF8N217YVLX • android-arm64 • Android 10 (API 29)
• No issues found!

Exception throws while Run the flutter plugin

Improperly formatted define flag: memory
FAILURE: Build failed with an exception.
Where: Script 'C:\newfluttersdk\flutter\packages\flutter_tools\gradle\flutter.gradle'
line: 896
What went wrong: Execution failed for task ':app:compileFlutterBuildDebug'.
Process 'command 'C:\newfluttersdk\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. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 2s Running Gradle task 'assembleDebug'... Running
Gradle task 'assembleDebug'... Done 3.3s
Exception: Gradle task assembleDebug failed with exit code 1
flutter doctor -v
[√] Flutter (Channel stable, 1.20.1, on Microsoft Windows [Version
10.0.18362.657], locale en-IN)
• Flutter version 1.20.1 at C:\newfluttersdk\flutter
• Framework revision 2ae34518b8 (5 days ago), 2020-08-05 19:53:19 -0700
• Engine revision c8e3b94853
• Dart version 2.9.0
[√] Android toolchain - develop for Android devices (Android SDK
version 29.0.3)
• Android SDK at C:\Users\DeepikaRavi\AppData\Local\Android\sdk
• Platform android-29, build-tools 29.0.3
• 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.
[√] Android Studio (version 4.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 48.1.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] VS Code, 64-bit edition (version 1.45.0)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension version 3.11.0
[√] Connected device (1 available)
• vivo Y51L (mobile) • 34d9bc20 • android-arm64 • Android 5.0.2 (API 21)
• No issues found!
Thanks in Advance.
#deepika can you please try this commands
flutter upgrade --force
flutter pub cache repair
cd <YOUR APP FOLDER>
flutter clean```
You should upgrade version android.
like that
android/build.gradle
classpath 'com.android.tools.build:gradle:4.1.1'
android/gradle/wrapper/gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
delete you yamillock file and run get pub it solve the issue for me