How to solve "Could not prepare isolate" error? - flutter

Installing build\app\outputs\flutter-apk\app.apk... 19.2s
E/flutter (23961): [ERROR:flutter/runtime/dart_isolate.cc(143)] Could not prepare isolate.
E/flutter (23961): [ERROR:flutter/runtime/runtime_controller.cc(385)] Could not create root isolate.
E/flutter (23961): [ERROR:flutter/shell/common/shell.cc(604)] Could not launch engine with configuration.
I do it flutter doctor but there no problem and I do it flutter clean and flutter run also but nothing run

Related

Flutter camera issue in android version 13

In android 13 we are facing the below issue we are using this third party camera plugin (https://pub.dev/packages/camera), I would really appreciate the help to solve the issue, Do we need to make some changes in our android version?
E/flutter (14764): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: CameraException(error, Attempt to invoke virtual method 'int android.media.EncoderProfiles$VideoProfile.getWidth()' on a null object reference)
E/flutter (14764): #0 AndroidCamera.createCamera (package:camera_android/src/android_camera.dart:112:7)
E/flutter (14764):
E/flutter (14764): #1 CameraController.initialize (package:camera/src/camera_controller.dart:291:19)
E/flutter (14764):
It's a well known issue that is being tracked here:https://github.com/flutter/flutter/issues/109769
some people came with a solution ( that I haven't tried ) but as of the current state the issue is still not fixed in the latest package version

Exception in flutter mobile_number package

I use mobile_number plugin, when try to implement example code I have a error:
ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: MissingPluginException(No implementation found for method hasPhonePermission on channel mobile_number)
E/flutter (11696): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:157:7)
E/flutter (11696): <asynchronous suspension>
E/flutter (11696): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:332:12)
E/flutter (11696): #2 MobileNumber.hasPhonePermission (package:mobile_number/mobile_number.dart:32:24)
The line which generate error is:
if (!await MobileNumber.hasPhonePermission) {
I use Flutter 1.22.6 • channel stable
mobile_number: ^1.0.3
What is the reason and how to avoid such a mistake?
p/s
I installed permissions in Manifest:
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.READ_CALL_LOG"/>
<uses-permission android:name="android.permission.ANSWER_PHONE_CALLS"/>
<uses-permission android:name="android.permission.READ_PHONE_NUMBERS" />
This is most likely due to the fact that you added the plugin and didn't rebuild your app again. Given that you followed the documentation on the pluginpage and added the mainactivity java requirements correct as instructed.
1- Close your emulator\debugging session.
2- Run flutter clean.
3- Give it a new try and it should work, update on the results of these steps please.

How to use "Image_picker" and "shared_preferences" together in the same project

The application works fine when I remove the "Image_picker" dependency.When I add back "shared_preferences" gives an error.
flutter run --release --verbose
This error is displayed when starting the application and when I want to use "shared_preferences".
[+8288 ms] E/flutter (10416): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: MissingPluginException(No implementation found
for method getAll on channel plugins.flutter.io/shared_preferences)
"Image_picke" gives this error.
[ +2 ms] E/flutter (10872):
[+18180 ms] E/flutter (10872): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: PlatformException(already_active, Image picker
is already active, null, null)
[ +3 ms] E/flutter (10872): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:581)
[ +1 ms] E/flutter (10872): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:158)
[ +1 ms] E/flutter (10872): <asynchronous suspension>
[ +2 ms] E/flutter (10872): #2 MethodChannelImagePicker.pickImage
(package:image_picker_platform_interface/src/method_channel/method_channel_image_picker.dart:29)
[ +2 ms] E/flutter (10872): <asynchronous suspension>
[ +1 ms] E/flutter (10872): #3 _PhotoAndNameState.takePicture (package:jokesapp/photoAndName.dart:22)
[ +1 ms] E/flutter (10872): <asynchronous suspension>
[ +2 ms] E/flutter (10872):
The error is fixed if I delete the dependency "Image_picker". But I have to use "Image_picker"
https://github.com/flutter/flutter/issues/40339 Someone mentioned this in this issues.
My better suggestion is to use your own channel to pick the image from native instead of using the third-party libraries, because sometimes you may get the plugin issues which will not be resolved and need to be waited until the plugin gets updated. Recently i faced the Permissions issue in flutter where i'm using permission_handler and the image_picker, the permission_handler i have used for microphone access, where as the image_picker will have their own permission checker. So when we include both the libraries in the project only one library will work because of the Override method of OnRequest and OnActivity.
The image_picker works for android 10 only in debug mode.
But I could not understand exactly what he was talking about. Since I will publish my application, "image_picker" is a safer choice for me.
I solved this problem days ago. Gradle version became 4.1.0 with new updates."Image_picker" dependency does not work in Gradle 4.1.0 version.Also, when it is in the same project with "shared_preferences" dependency, "shared_preferences" dependency also does not work.After removing "image_picker" from project, "shared_preferences" works correctly.So when we include both the libraries in the project only one library will work because of the Override method of OnRequest and OnActivity.
For more information.
#40339
SOLUTION
Sorry, the only solution is to drop the gradle version.
classpath 'com.android.tools.build:gradle:3.5.4'
I made the gradle version 3.5.4 and now everything works fine.
After lowering the Gradle version, if you get the NDK error, reduce the NDK version at the same time.
#76393

MissingPluginException(No implementation found for method pickImage on channel plugins.flutter.io/image_picker)

Unhandled Exception: MissingPluginException(No implementation found for method pickImage on channel plugins.flutter.io/image_picker)
E/flutter (16028): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:159:7)
E/flutter (16028): <asynchronous suspension>
E/flutter (16028): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:334:12)
E/flutter (16028): #2 MethodChannelImagePicker.pickImagePath (package:image_picker_platform_interface/src/method_channel/method_channel_image_picker.dart:62:21)
E/flutter (16028): #3 MethodChannelImagePicker.pickImage (package:image_picker_platform_interface/src/method_channel/method_channel_image_picker.dart:30:25)
E/flutter (16028): #4 ImagePicker.getImage (package:image_picker/image_picker.dart:101:21)
STEP 1 : Ensure you have imported the plugin by including this in your pubspec.yaml file
image_picker: ^0.6.7+4
STEP 2 : Make sure you have imported the plugin in the file you need it
import 'package:image_picker/image_picker.dart';
STEP 3 : Make sure you run this command
flutter pub get
Now, many times in Flutter even after doing the above 3 steps perfectly you will get the same error.
Here is my solution that has worked for me.
STEP 1 : Run this command in the terminal
flutter clean
STEP 2 : CLOSE/STOP your emulator and start it again
99% of the time this works for me.
just click stop red icon right side of run icon. and restart app

The Flutter SDK is installed in a protected folder and may not function correctly

The Flutter SDK is installed in a protected folder and may not function correctly.Please move the SDK to a location that is user-writable without Administration permissions and restart.
Above warning pops up when i open the VSCode even though i am running it as administrator.
My flutter sdk resides in c:\program files\flutter
And when I try to run any flutter command from either vscode terminal or cmd(run as admin) it gives below error:
Unhandled exception:
SocketException: OS Error: A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied.
, errno = 10057, address = 169.254.169.254, port = 49839
#0 AzureDetector.isRunningOnAzure (package:flutter_tools/src/base/bot_detector.dart:91:41)
<asynchronous suspension>
#1 BotDetector.isRunningOnBot (package:flutter_tools/src/base/bot_detector.dart:66:31)
#2 isRunningOnBot (package:flutter_tools/src/globals.dart:77:48)
#3 run (package:flutter_tools/runner.dart:38:36)
#4 main (package:flutter_tools/executable.dart:67:9)
#5 main (file:///C:/Program%20Files/flutter/packages/flutter_tools/bin/flutter_tools.dart:8:3)
#6 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
#7 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)```
The program files folder is protected in windows. you should not install flutter there. move it to another directory like c:\src\flutter and then go to Environment variables add the new directory's bin folder to path.
The initial warning about protected folder went away thanks to the accepted answer. But was still getting the error on running any flutter commands. My problem solved when i upgraded the flutter version and now i can run any command.