Unable to run flutter app in android studio - flutter

I created a new flutter project and when run it, it gives that error
Target kernel_snapshot failed: Exception: The value of -DDartDefines is not formatted correctly.
The value must be a JSON-encoded list of strings but was:
[flutter.inspector.structuredErrors=true]
build failed.
FAILURE: Build failed with an exception.
* Where:
Script 'D:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 882
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'D:\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
Exception: Gradle task assembleDebug failed with exit code 1
I have tried flutter clean, and same error
flutter doctor log :
D:\flutter\bin\flutter.bat doctor --verbose
[√] Flutter (Channel master, v1.16.4-pre.69, on Microsoft Windows [Version 10.0.18363.959], locale en-US)
• Flutter version 1.16.4-pre.69 at D:\flutter
• Framework revision 19e7db585d (4 months ago), 2020-04-01 11:16:01 -0700
• Engine revision c9506cb8e9
• Dart version 2.8.0 (build 2.8.0-dev.18.0 eea9717938)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at C:\Users\user\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)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[√] Android Studio (version 4.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 47.1.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[!] VS Code (version 1.47.2)
• VS Code at C:\Users\user\AppData\Local\Programs\Microsoft VS Code
X Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[!] Connected device
! No devices available
! Doctor found issues in 3 categories.
Process finished with exit code 0

According to what flutter doctor is giving you the problem might be related to Android Sdk not installed or not configured really well:
Flutter provides a command to update the Android SDK path: Use
flutter config --android-sdk <path-to-your-android-sdk-path>
You can install it directly from Android Studio:
To open the SDK Manager from Android Studio, click Tools > SDK Manager or click SDK Manager in the toolbar. You might have to uncheck "hide obsolete packages" and install the packages that were considered obsoletes.
Or you can install it from this link and configure it like I said before:
https://www.google.com/url?sa=t&source=web&rct=j&url=https://android-sdk.fr.uptodown.com/windows&ved=2ahUKEwi-itWCkuzqAhXTZTUKHa29CRMQFjACegQIAhAB&usg=AOvVaw1QSSVVMrZzFltXvboDbTeQ

Related

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

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

Warning! The 'flutter' tool you are currently running is from a different Flutter repository than the one last used by this package

Everytime i try to build an apk or appbundle, this error comes up. please help.
Warning! The 'flutter' tool you are currently running is from a different Flutter repository than the one last used by this package. The repository from which the 'flutter' tool is currently executing will be u
sed instead.
running Flutter tool: C:\Users\MOMO\Mygit\flutter
previous reference : C:\flutter
This can happen when you have multiple copies of flutter installed. Please check your system path to verify that you are running the expected version (run 'flutter --version' to see which flutter is on your pat
h).
Compiler message:
/C:/flutter/packages/flutter/lib/src/rendering/layer.dart:1580:36: Error: 'ImageFilterEngineLayer' isn't a type.
oldLayer: _engineLayer as ui.ImageFilterEngineLayer,
^^^^^^^^^^^^^^^^^^^^^^
/C:/flutter/packages/flutter/lib/src/rendering/layer.dart:1578:27: Error: The method 'pushImageFilter' isn't defined for the class 'SceneBuilder'.
'SceneBuilder' is from 'dart:ui'.
Try correcting the name to the name of an existing method, or defining a method named 'pushImageFilter'.
engineLayer = builder.pushImageFilter(
^^^^^^^^^^^^^^^
Target kernel_snapshot failed: Exception: Errors during snapshot creation: null
build failed.
FAILURE: Build failed with an exception.
Where:
Script 'C:\Users\MOMO\Mygit\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 780
What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
Process 'command 'C:\Users\MOMO\Mygit\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 14s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 15.7s
Gradle task assembleRelease failed with exit code 1
Thats my flutter doctor -v
[√] Flutter (Channel stable, v1.12.13+hotfix.9, on Microsoft Windows [Version 10.0.18363.778], locale en-US)
• Flutter version 1.12.13+hotfix.9 at C:\Users\MOMO\Mygit\flutter
• Framework revision f139b11 (4 weeks ago), 2020-03-30 13:57:30 -0700
• Engine revision af51afceb8
• Dart version 2.7.2
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at C:\Users\MOMO\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• Java binary at: D:\Android\Android Studio1\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:\Android\Android Studio1
• Flutter plugin version 45.0.1
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
[√] IntelliJ IDEA Ultimate Edition (version 2019.3)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.1
• Flutter plugin version 45.0.2
• Dart plugin version 193.5731
[!] Connected device
! No devices available
! Doctor found issues in 1 category.

How to fix 'Error running gradle # line 24'

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.

"Flutter Code extension not installed" but it's been installed for months

Have been using Flutter with VSCode on Mac for months without issues, but suddenly flutter doctor produces this:
[✓] Flutter (Channel beta, v0.5.1, on Mac OS X 10.13.4 17E202, locale en-US)
• Flutter version 0.5.1 at [Path]/flutter
• Framework revision c7ea3ca377 (3 weeks ago), 2018-05-29 21:07:33 +0200
• Engine revision 1ed25ca7b7
• Dart version 2.0.0-dev.58.0.flutter-f981f09760
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
• Android SDK at [Path]/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-27, build-tools 27.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
• All Android licenses accepted.
[✓] iOS toolchain - develop for iOS devices (Xcode 9.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 9.3.1, Build version 9E501
• ios-deploy 1.9.2
• CocoaPods version 1.5.2
[✓] Android Studio (version 3.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 25.0.1
• Dart plugin version 173.4700
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
[!] VS Code (version 1.24.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected devices (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)
! Doctor found issues in 1 category.
I can confirm that flutter is installed, and nothing has changed since I started using it. Additionally, before I updated flutter (today), flutter doctor read, under VSCode, as:
[!] VS Code (version 1.24.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Dart Code extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.dart-code
However, post-upgrade that seems the inability to find dart might have been fixed.
There is a post from a few days ago here that indicates flutter doctor may just be inaccurate for the time being, so I tried to run the project, and got the following error stack:
Using hardware rendering with device Android SDK built for x86.
If you get graphics artifacts, consider enablingsoftware rendering with "--enable-software-rendering".
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle... 2.0s
Resolving dependencies... 2.2s
Running 'gradlew assembleDebug'...
Error: unable to locate asset entry in pubspec.yaml:
"ios/Flutter/flutter_assets/fonts/MyFlutterApp.ttf".
Error building assets
FAILURE: Build failed with an exception.
* Where:
Script
'[Path]/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 435
* What went wrong:
Execution failed for task ':app:flutterBuildDebug'.
> Process 'command
'[Path]/flutter/bin/flutter'' 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 17s
Gradle build failed: 1
MacBook-Pro-3:rambleapp TrentKennelly$ flutter trace
Error connecting to observatory: Exception: Attempted to connect to Dart
observatory 5 times, and all attempts failed. Giving up. The URL was
ws://127.0.0.1:8100/ws
Any thoughts on this?
There was a change in VSCode that broke extensions detection. It's safe to ignore this warning.
See the full comment of Danny Tuppeny, about this issue here.
For the stacktrace there are two things:
The asset "ios/Flutter/flutter_assets/fonts/MyFlutterApp.ttf"was
not found
The issue with obsvervatory
Did you check the asset still exists?
The project does not compile without it, and the observatory issue may be related to this.
Install the Flutter extension within VS Code.