After sound null safety has arrived, projects that still have dependencies that have not upgraded to null safety yet, can still be run using --no-sound-null-safety flag through the Flutter command.
But now I am trying to run the app through the android project. The reason why I am trying to do this way is to allow me to debug a native Flutter plugin. I open the folder android on Android Studio and when I try to run the project I receive an error:
Error: Cannot run with sound null safety, because the following dependencies don't support null safety:
If I was running through the Flutter command, the flag I mentioned would work here. But how do I set this flag when running the android project through Android Studio?
Change your edit configurations.
Add the flag --no-sound-null-safety
After searching a little more I found the solution to this problem. You do not need to run the project through Android Studio, you can run it with the Flutter command and then attach the debugger using Android Studio.
Reference: https://stackoverflow.com/a/58760445/8633918
Related
I am using Android Studio as SDK Platforms and SDK Tools. Currently, I have a problem when running the android emulator using Visual Studio. I have checked flutter doctor and no issues has been found. However, it shows an error as below.
As i run flutter run --verbose to search for the problems, it shows more details of the error as below
Just for sharing. Since I installed android studio, visual studio and flutter in my device using windows 11 pro, it doesn't work. However, I solved this problem by downgrading the Windows version into Windows 10 Home and it solved this particular problem. Anyone who face the same issue might try this in your current device.
This look like gradle compatibility issue.
Step to solve.
create new flutter project. try to compile the prject, if it work fine.
compare the android folder with yours and replace what is missing with the new flutter project you created.
sync your project after.
file/invalidateCache
flutter clean
flutter pub get
flutter run
you should be fine
To solve your error you have to update your compileSDKversion to the newest version which is currently 31.
You can find the compileSDKversion inside android > app > build.gradle
android {
compileSdkVersion 31
...
}
Note: you have to close and open android studio again
This application is not configured to build on the web.
To add web support to a project, run flutter create ..
Launching lib\main.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome...
Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:
package:flutter_speed_dial
For solutions, see https://dart.dev/go/unsound-null-safety
Unhandled exception:
You will need at least version 3.0.0 of that package to have null safety.
Given that they are at version 5.0.0 right now, you should probably update your packages every once in a while.
If you want to run without latest version you need to Update the Configuration File,
Edit Configuration
Then,
Add --no-sound-null-safety in Additional run args.
Add Command in Additional run args
Then, Click Apply and Run the app.
Edited:
you will need to latest version and if you want to run without latest version you need to run this command
$ flutter run --no-sound-null-safety
I have shifted my entire code to latest dart version 2.15.1. Now I am trying to run the code and it is giving this error.
Image1
Why I am getting this error. Anyone please help me.
Thanks
This is because some of your dependencies that you are using in your project doesn't support null-safety or Your project itself doesn't support null-safety but using dependencies that supports null-safety. To get rid of this problem you can try upgrading the dependency that is causing the error and if there's no update available for that plugin that run your project using below command :
To Run
flutter run --no-sound-null-safety
To Build
flutter build apk --release --no-sound-null-safety
This error comes when your project or package is not supported on null safety
when you are trying to run the project its gives you an error which you see in your picture
if you want to run without null safety use this command
flutter run --no-sound-null-safety
when you hit this command on your project it should be run if you face any error kindly comment
Press Run
Edit Configurations
Add Additional Run args
--no-sound-null-safety
I just ran into this. I tried to build for Windows and got the null-safety error but the output did not say which packages were the problem, it just showed several paths to Visual Studio.
I then tried to build for Chrome and it did list the packages that did not support null-safety. Hope this helps.
in my case i just type the major version avalaible for the dependency and it works!
from
shared_preferences:
to
shared_preferences: ^2.0.16
With the flutter pub update command, it threw me a reference to the shared_preferences dependency and after investigated options I saw this solution and applied it and it worked fine
My flutter application is using a plugin that has been discontinued. The app runs well in an emulator but android studio gives out the message 'java uses or overrides a deprecated API' when I try to build an apk. I don't want to go through the hassle of finding a different plugin now and change the code everywhere. Is there a way to build the apk on android studio without having to update dependencies?
ps. I'm creating this app purely for coding practice.
i had same problem and these follow steps solved my problem:
flutter clean
flutter pub get
flutter build apk --release --split-per-abi
if there is a deprecated api, it will recompile with -Xlint
I am new to flutter and I got this error when I tried to run the flutter run command. I found many articles related to this issue and got to know that flutter run --no-sound-null-safety is the solution to this issue during development. But my question is that What if I get this error during the production build? How can I handle it there?
flutter build <target> --no-sound-null-safety works too (as does flutter test --no-sound-null-safety FYI).
Note that this is a compilation error. If it fails, you won't get your APK (or whatever you're targeting), so this is not something you need to worry about happening "in production".
However, if you're new to Flutter, and the project is still young, consider trying to remove the null-unsafe dependencies. The command flutter pub outdated --mode=null-safety will give you info on which packages don't support null safety, and whether they can be upgraded.