Reputation: 93
I am answering my own question here because I solved it after many hours of searching. This is NOT an already answered question, so please don't tag it as such. I wish it was, it would've saved me hours of frustration.
Flutter project is failing with this error. Fluttertoast error.
??: ?? ContextCompat
??: ? FluttertoastPlugin
2 ???
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':fluttertoast:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
*
Get more help at https://help.gradle.org
BUILD FAILED in 26s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility for more information on the problem and how to fix it.
*******************************************************************************************
Finished with error: Gradle task assembleDebug failed with exit code 1
Upvotes: 0
Views: 6293
Reputation: 1645
In my case. I updated all dependencies in pubspec.yaml
and it worked.
Upvotes: 1
Reputation: 375
In my case all I did was run
flutter clean
and rerun project and everything worked fine.
Upvotes: 0
Reputation: 93
The underlying issue is that the android.support.v4.Content.ContextCompat import in fluttertoastplugin.java can't resolve the symbol ContextCompat. This is a dependency issue.
The solution is to go to your flutter project's pubspec.yaml and find the fluttertoast dependency and update it to the latest version (currently ^3.1.0)
dependencies:
flutter:
sdk: flutter
dropdown_formfield: ^0.1.0
camera: ^0.5.2+1
fluttertoast: ^3.1.0 <----- THIS ONE
path_provider: ^1.1.0
video_player: ^0.10.1
latlong: ^0.6.1
google_maps_flutter: ^0.5.11+1
http: ^0.12.0
flutter_blue: ^0.5.0
flutter_bluetooth_serial: ^0.0.5
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
Upvotes: 2