Exception: Gradle task assembleDebug failed with exit code 1, visual studio code - android

my app was running normally , after running flutter upgrade it gives me this error . I didn't change anything in my code.
note: I am using visual studio code
I tried flutter clean, flutter upgrade but it gives the same error .
I checked JAVA_HOME path and it is okay
../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.18.1/lib/src/picture_provider.dart:50:59: Error: No named parameter with the name
'nullOk'.
context != null ? Localizations.localeOf(context, nullOk: true) : null,
^^^^^^
../../flutter/packages/flutter/lib/src/widgets/localizations.dart:413:17: Context: Found this candidate, but the arguments don't match.
static Locale localeOf(BuildContext context) {
^^^^^^^^
FAILURE: Build failed with an exception.
* Where:
Script 'D:\mobileapps\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 991
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'D:\mobileapps\flutter\bin\flutter.bat'' finished with non-zero exit value 1
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 49s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 50.5s
Exception: Gradle task assembleDebug failed with exit code 1
this is the result of run doctor -v
[√] Flutter (Channel stable, 2.0.1, on Microsoft Windows [Version 10.0.18362.30], locale en-US)
• Flutter version 2.0.1 at D:\mobileapps\flutter
• Framework revision c5a4b4029c (7 days ago), 2021-03-04 09:47:48 -0800
• Engine revision 40441def69
• Dart version 2.12.0
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
• Android SDK at C:\Users\hit-ham\AppData\Local\Android\sdk
• Platform android-29, build-tools 30.0.1
• 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 version 47.1.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
rosoft VS Code
• Flutter extension version 3.20.0
[√] Connected device (2 available)
• GM1910 (mobile) • bb671501 • android-arm64 • Android 10 (API 29)
• Chrome (web) • chrome • web-javascript • Google Chrome 88.0.4324.190
• No issues found!

You should update the package 'flutter_svg' from 0.18.1 to 0.19.3 and it should solve your issue,
it happens because of the 'nullOk' parameter that was removed in Flutter 2. You can read about it here:
https://flutter.dev/docs/release/breaking-changes/eliminating-nullok-parameters
I found this solution and it worked for me

Related

Flutter Execution failed for task ':app:processDebugResources'. Could not resolve all dependencies for configuration ':app:debugCompileClasspath'

Flutter project stopped building today all of a sudden.
Here's the full error:
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Could not resolve all dependencies for configuration ':app:debugCompileClasspath'.
> Problems reading data from Binary store in /private/var/folders/_5/q7ql37gj5k7f37d865zhzl8c0000gn/T/gradle18017070233811730283.bin offset 35036 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 28s
Running Gradle task 'assembleDebug'... 29.7s
Exception: Gradle task assembleDebug failed with exit code 1
I have tried:
flutter clean, deleted pubspec.lock and flutter pub cache repair to get rid of cache and reinstall packages but nothing.
flutter downgrade, got the same error.
Fresh reinstall of flutter, same thing.
Fresh git clone of the project, nothing.
Any hints?
Here's my flutter doctor -v:
[✓] Flutter (Channel stable, 2.8.1, on macOS 12.1 21C52 darwin-arm, locale
en-GB)
• Flutter version 2.8.1 at /Users/gracielacarrillo/Development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 77d935af4d (4 weeks ago), 2021-12-16 08:37:33 -0800
• Engine revision 890a5fca2e
• Dart version 2.15.1
[✓] Android toolchain - develop for Android devices (Android SDK version
31.0.0)
• Android SDK at /Users/gracielacarrillo/Library/Android/sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: /Applications/Android
Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2020.3)
• 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 11.0.10+0-b96-7249189)
[✓] VS Code (version 1.63.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.32.0
[✓] Connected device (2 available)
• sdk gphone arm64 (mobile) • emulator-5554 • android-arm64 • Android 11
(API 30) (emulator)
• Chrome (web) • chrome • web-javascript • Google
Chrome 97.0.4692.71
• No issues found!
Maybe you are getting errors because of jcenter. Follow the link and switch to mavenCenteral.
Switch to Maven Central

Why can't I build in flutter?

i run the build in flutter, it will not proceed at this stage, below is the status of flutter doctor.
I don't know which part is wrong.
I get the following error, the installed package doesn't seem to match the version of flutter, but I don't know how to fix it.
Launching lib/main.dart on Android SDK built for arm64 in debug mode...
lib/main.dart:1
Note: /Users/madol.eeee/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/geocoding-2.0.1/android/src/main/java/com/baseflow/geocoding/GeocodingPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
/Users/madol.eeee/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/geolocator_android-2.0.0/android/src/main/java/com/baseflow/geolocator/location/LocationMapper.java:29: error: cannot find symbol
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
^
symbol: variable S
location: class VERSION_CODES
/Users/madol.eeee/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/geolocator_android-2.0.0/android/src/main/java/com/baseflow/geolocator/location/LocationMapper.java:30: error: cannot find symbol
position.put("is_mocked", location.isMock());
^
symbol: method isMock()
location: variable location of type Location
2 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':geolocator_android:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* 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 7s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
flutter doctor -v
[✓] Flutter (Channel stable, 2.5.2, on macOS 11.6 20G165 darwin-arm, locale ko-KR)
• Flutter version 2.5.2 at /Users/madol.eeee/Downloads/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 3595343e20 (7 days ago), 2021-09-30 12:58:18 -0700
• Engine revision 6ac856380f
• Dart version 2.14.3
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/madol.eeee/Library/Android/sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: /Users/madol.eeee/Downloads/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 13.0, Build version 13A233
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2020.3)
• Android Studio at /Users/madol.eeee/Downloads/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 11.0.10+0-b96-7249189)
[✓] VS Code (version 1.60.2)
• VS Code at /Users/madol.eeee/Downloads/Visual Studio Code.app/Contents
• Flutter extension version 3.27.0
[✓] Connected device (2 available)
• sdk gphone arm64 (mobile) • emulator-5554 • android-arm64 • Android 11 (API 30) (emulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 94.0.4606.71
Open Android Studio--> Tools --> AVD Manager
wipedata of simulator
again run

Flutter: FAILURE: Build failed with an exception on Could not create task ':app:compileFlutterBuildDebug'. Must provide Flutter source directory

Recently I immigrated my project to a new system and rectified all the errors but I got an exception that says provide flutter source directory.
I added the flutter SDK path and checked but I still couldn't solve the
problem.
FAILURE: Build failed with an exception.
* Where:
Script 'C:\src\flutterSDK\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 572
* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
> Could not create task ':app:compileFlutterBuildDebug'.
> Must provide Flutter source directory
* 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.
I have run the Flutter doctor cmd and everything is fine
flutter doctor -v
[√] Flutter (Channel stable, 2.5.0, on Microsoft Windows [Version 10.0.19043.1165], locale en-IN)
• Flutter version 2.5.0 at C:\src\flutterSDK\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 4cc385b4b8 (6 days ago), 2021-09-07 23:01:49 -0700
• Engine revision f0826da7ef
• Dart version 2.14.0
[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at C:\Users\Barfi Nandeti\AppData\Local\Android\sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Android Studio (version 2020.3)
• 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 11.0.10+0-b96-7249189)
[√] VS Code (version 1.60.0)
• VS Code at C:\Users\Barfi Nandeti\AppData\Local\Programs\Microsoft VS Code
• Flutter extension can be installed from:
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[√] Connected device (2 available)
• Chrome (web) • chrome • web-javascript • Google Chrome 93.0.4577.63
• Edge (web) • edge • web-javascript • Microsoft Edge 93.0.961.47
• No issues found!
This is probably because the flutter SDK is in a different directory than your old machine. Checkout this answer.

Cannot run flutter application on first run, gradle error

I have created a new flutter app and I cannot get it to run for the first time. It gets stuck at running Gradle task assembleDebug. This is the error message I get
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:stripDebugDebugSymbols'.
> NDK at C:\Users\Hp\AppData\Local\Android\sdk\ndk-bundle did not have a source.properties file
* 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 3m 10s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
I have ran flutter doctor and this are the results
[√] Flutter (Channel stable, 2.0.0, on Microsoft Windows [Version 10.0.19041.804], locale en-US)
• Flutter version 2.0.0 at C:\dev\flutter
• Framework revision 60bd88df91 (2 days 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\Hp\AppData\Local\Android\sdk
• Platform android-30, build-tools 30.0.3
• Java binary at: C:\Program Files\Android\Android Studio1\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.1.0)
• Android Studio at C:\Program Files\Android\Android Studio1
• 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.54.1)
• VS Code at C:\Users\Hp\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.20.0
[√] Connected device (3 available)
• Redmi 6 (mobile) • a28707477d26 • android-arm • Android 9 (API 28)
• 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!
Base from the error, the NDK build in your machine can't be used. One way to resolve this issue is by deleting the current NDK and have Flutter download a new NDK build. Head over to the NDK path provided in the error and delete ndk-bundle folder, then run flutter clean in the terminal. Running the app again should automatically run flutter pub get to rebuild all the references and dependencies.

What went wrong: Execution failed for task ':fluttertoast:compileDebugKotlin'

After updating my flutter project when I was going to run the application in the android studio, I got the following error.
e: C:\Users\user\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\fluttertoast-7.1.5\android\src\main\kotlin\io\github\ponnamkarthik\toast\fluttertoast\MethodCallHandlerImpl.kt: (16, 16): Redeclaration: MethodCallHandlerImpl
e: C:\Users\user\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\fluttertoast-7.1.6\android\src\main\kotlin\io\github\ponnamkarthik\toast\fluttertoast\MethodCallHandlerImpl.kt: (17, 16): Redeclaration: MethodCallHandlerImpl
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':fluttertoast:compileDebugKotlin'.
> Compilation error. See log for more details
* 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 52s
Exception: Gradle task assembleDebug failed with exit code 1
I tried following steps but I was not able to fix this.
pub get, pub upgrade
And here's my flutter doctor result
"C:\Program Files\flutter\bin\flutter.bat" doctor --verbose
[√] Flutter (Channel stable, 1.22.4, on Microsoft Windows [Version 10.0.19042.804], locale en-US)
• Flutter version 1.22.4 at C:\Program Files\flutter
• Framework revision 1aafb3a8b9 (3 months ago), 2020-11-13 09:59:28 -0800
• Engine revision 2c956a31c0
• Dart version 2.10.4
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at C:/Users/user/AppData/Local/Android/Sdk
• Platform android-30, build-tools 30.0.2
• ANDROID_HOME = C:/Users/user/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)
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.
[!] Android Studio (version 4.1.0)
• Android Studio at C:\Program Files\Android\Android Studio
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[!] VS Code (version 1.53.0)
• 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 (1 available)
• sdk gphone x86 arm (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator)
! Doctor found issues in 3 categories.
Process finished with exit code 0
How can I fix this issue?
This was happened due to a pub cache conflict. The problem was fixed after executing the following command in the terminal.
dart pub cache repair
dart pub get
dart pub upgrade
I tried your solution but it does not work for me. My solution is update compileSdkVersion to 30 in my app/build.gradle.
Update the flutter toast version to latest fluttertoast version in dependencies in pubspec.yaml . It worked for me.
I got the same error. Tried updating compileSdkVersion. Didn't work for me. This solved my problem.
pubspec.yaml -->> pub upgrade
Change fluttertoast version to latest
Pub get
Run...

Categories

Resources