我在这里回答自己的问题,因为经过数小时的搜索,我解决了。这不是一个已经回答的问题,所以请不要这样标记。我希望是的,这样可以节省我数小时的沮丧。
Flutter项目因此错误而失败。 Fluttertoast错误。
??: ?? 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
答案 0 :(得分:0)
潜在的问题是fluttertoastplugin.java中的android.support.v4.Content.ContextCompat导入无法解析符号ContextCompat。这是一个依赖性问题。
解决方案是转到flutter项目的pubspec.yaml,找到fluttertoast依赖项并将其更新到最新版本(当前为^ 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
答案 1 :(得分:0)
就我而言,我所做的只是奔跑了
flutter clean
并重新运行项目,一切正常。
答案 2 :(得分:0)
就我而言。我更新了pubspec.yaml
中的所有依赖项,并且有效。