Flutter Pub Get command failed - flutter

I'm getting this error message on running the command : flutter pub get
Failed to decode data using encoding 'utf-8', path = 'C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_tts-1.2.6\pubspec.yaml'
Running "flutter pub get" in dhiyo-app...
pub get failed (66; Failed to decode data using encoding 'utf-8', path = 'C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_tts-1.2.6\pubspec.yaml')

Related

Accidently replaced '.r' through whole app with '' in flutter project

I had lots of reference of '.r' through my flutter app and I replaced all '.r' references with '' empty string and I came to to know that dart files also have been modified and now I get these errors in my debug console. I tried to fix these but seems like re-adding '.r' isn't fixing these problems.
Debug Console:
Launching lib\main.dart on sdk gphone x86 in debug mode...
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.1.3/lib/src/path_provider_windows_real.dart:117:66: Error: Member not found: 'roamingAppData'.
final String? appDataRoot = await
getPath(WindowsKnownFolder.roamingAppData);
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.1.3/lib/src/path_provider_windows_real.dart:146:60: Error: The method 'rsetGUID' isn't defined for the class 'GUID'.
'GUID' is from 'package:win32/src/guid.dart' ('/C:/flutter/.pub-cache/hosted/pub.dartlang.org/win32-3.0.1/lib/src/guid.dart').
Try correcting the name to the name of an existing method, or defining a method named 'rsetGUID'.
final Pointer knownFolderID =
calloc().ref.rsetGUID(folderID);
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.1.3/lib/src/path_provider_windows_real.dart:235:5: Error: Expected an identifier, but got '.'.
Try inserting an identifier before '.'.
.replaceAll(RegExp(r'[<>:"/\\|?*]'), '_');
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.1.3/lib/src/path_provider_windows_real.dart:237:9: Error: Expected an identifier, but got '.'.
Try inserting an identifier before '.'.
.trimRight();
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.1.3/lib/src/path_provider_windows_real.dart:239:5: Error: Expected an identifier, but got '.'.
Try inserting an identifier before '.'.
.replaceAll(RegExp(r'[<>:"/\|?*]'), '_');
FAILURE: Build failed with an exception.
Where:
Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1159
What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
Process 'command 'C:\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 10s Exception: Gradle task assembleDebug failed with exit code 1 Exited (sigterm)

Error: 'kethrow' isn't a type. kethrow _ClientSocketException(error, request.url);

Building flutter application is giving an error.When i try to build my application the error is occured.
The error is:
**/C:/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.13.5/lib/src/io_client.dart:88:7: Error: 'kethrow' isn't a type.
kethrow _ClientSocketException(error, request.url);
^^^^^^^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.13.5/lib/src/io_client.dart:88:15: Error: Expected ';' after this.
kethrow _ClientSocketException(error, request.url);
^^^^^^^^^^^^^^^^^^^^^^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.13.5/lib/src/io_client.dart:88:43: Error: Expected ')' before this.
kethrow _ClientSocketException(error, request.url);
^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.13.5/lib/src/io_client.dart:48:30: Error: A non-null value must be returned since the return type 'IOStreamedResponse' doesn't allow null.
- 'IOStreamedResponse' is from 'package:http/src/io_streamed_response.dart' ('/C:/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.13.5/lib/src/io_streamed_response.dart').
package:http/src/io_streamed_response.dart:1
Future<IOStreamedResponse> send(BaseRequest request) async {
^
3
FAILURE: Build failed with an exception.
* Where:
Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1156
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\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 5m 45s
Exception: Gradle task assembleDebug failed with exit code 1**
How to fix this error.Thanks in advance.
I ran into this error a few days ago. It is strangely from the dart file. Mine was 'heethrow'. I corrected it by following the link to the file: /C:/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.13.5/lib/src/io_client.dart.
How to go about it:
Open location /C:/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.13.5/lib/src/ in Visual Studio Code
inside the src folder, open io_client.dart
(make sure you're in the io_client.dart inside the src folder)
Once you're in io_client.dart, locate the place with the error: in your case, it says 88:7 that is, line 88 column 7. Scroll to line number 88 and change 'kethrow' to 'throw'
the errors in the other places as marked in the image below should be corrected and your io_client.dart should be error free.
Note: other files outside io_client.dart might mark red indicating errors but never mind. Just save your changes in the io_client.dart file and close the file. Once closed
Open your project again and run flutter clean in the terminal.
next run flutter pub get
next run flutter pub upgrade
run your app again, everything should work fine.
But I'd advise you don't always go into those files to edit anything. I did that because I've tried every possible solution and needed to deliver my work. I even installed Visual Studio for Windows as suggested by flutter doctor, but that was not the solution.

Creation failed with Flutter code Obfuscating

I am following this guide: https://flutter.dev/docs/deployment/obfuscate
Running Flutter 1.17.5 • channel stable
When I run:
flutter build apk --obfuscate --split-debug-info=/sample/debug --target-platform android-arm,android-arm64,android-x64
Then I get the following error:
Target android_aot_release_android-arm failed: FileSystemException: Creation failed, path =
'/sample' (OS Error: Read-only file system, errno = 30)
Target android_aot_release_android-x64 failed: FileSystemException: Creation failed, path =
'/sample' (OS Error: Read-only file system, errno = 30)
Target android_aot_release_android-arm64 failed: FileSystemException: Creation failed, path =
'/sample' (OS Error: Read-only file system, errno = 30)
build failed.
FAILURE: Build failed with an exception.
* Where:
Script '/Users/user/Developer/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 882
* What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
> Process 'command '/Users/user/Developer/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. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
You should provide a relative path from your root:
flutter build apk --obfuscate --split-debug-info=./sample/debug

Error when Input is : C:\src\flutter>flutter doctor

On setting up Flutter:
error :CreateProcessW failed 193
CreateProcessW failed 193
Unhandled exception:
ProcessException: %1 is not a valid Win32 application.
i have Tried changing username
from the Command prompt run the flutter doctor inside the flutter installation directory:
C:\src\flutter> flutter doctor

Library 'uuid' from dart doesn't work with flutter?

I tried flutter run after adding the dependencies of the Dart Library Uuid.
My changed dependencies
dependencies:
uuid: 0.5.0 // or also - uuid: "^0.5.3"
Errors from Flutter
Error: 'package:convert/src/hex/encoder.dart': malformed type: line 20 pos 13: cannot resolve class 'ChunkedConverter' from 'HexEncoder'
extends ChunkedConverter<List<int>, String, List<int>, String> {
^
Failed to run the Flutter compiler. Exit code: 254
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\xxxx\Flutter\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 329
* What went wrong:
Execution failed for task ':app:flutterBuildDebug'.
> Process 'command 'C:\Users\xxxx\Flutter\flutter\bin\flutter.bat'' finished with non-zero exit value 254
Why does this not work with flutter?
After reading https://github.com/dart-lang/sdk/issues/29543#issuecomment-298888237 I think you might want to try adding a pubspec dependency on convert: "^2.0.1". Does that help?