Home > Back-end >  Flutter: Android instrumentation test - how to provide no sound null safety argument to gradlew comm
Flutter: Android instrumentation test - how to provide no sound null safety argument to gradlew comm

Time:04-26

While working with integration tests for a flutter app (which is currently in migration stage to sound null safety), the gradlew app:assembleDebug -Ptarget=<path_to_test>.dart command failed with an error

Error: A library can't opt out of null safety by default, when using sound null safety.

As per the documentation from flutter repository , this step is required to generate a test apk that can be later uploaded to firebase test lab.

Is there a way to pass --no-sound-null-safety argument to the gradlew command?

CodePudding user response:

Currently there is no way to pass the --no-sound-null-safety argument to the gradlew command as this is a flutter feature.

The workaround was to make the entry point of the app file use dart 2.9 which is non null safety type.

// @dart=2.9

void main(){
    
}

On making the main() entry file for the integration test, the gradlew command was able to assemble the app without any additional commands.

CodePudding user response:

Yes: --no-sound-null-safety

gradlew app:assembleDebug -Ptarget=<path_to_test>.dart --no-sound-null-safety

Hope it helps!

  • Related