How to Handle "Cannot run with sound null safety" error with Visual Studio AppCenter in Flutter APK Build


I’m trying to add AppCenter to my application but I get build error:

Error: Cannot run with sound null safety, because the following
dependencies don’t support null safety:

  • package:appcenter
  • package:appcenter_analytics
  • package:appcenter_crashes

For solutions, see

FAILURE: Build failed with an exception.

I added auto-generated code from AppCenter to my ->app/build.gradle

dependencies {
    def appCenterSdkVersion = '4.3.1'
    implementation "${appCenterSdkVersion}"
    implementation "${appCenterSdkVersion}"


Spending some hours in pain, I found my solution and post it here

We should not import appcenter, appcenter_analytics appcenter_crashespackage in main.dart (also not import them into pubspec.yaml)
What we should do is, override "onCreate" method in and implement appcenter there.
You can find more details in my answer.

Answered By – Aurora

Answer Checked By – Marie Seifert (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *