'Flutter: Android instrumentation test - how to provide no sound null safety argument to gradlew command
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?
Solution 1:[1]
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.
Solution 2:[2]
Yes: --no-sound-null-safety
gradlew app:assembleDebug -Ptarget=<path_to_test>.dart --no-sound-null-safety
Hope it helps!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | krishnakumarcn |
| Solution 2 | liam spiegel |
