使用firebase_auth时Flutter Windows构建失败:encodable_value.h中std::variant错误
Flutter Windows集成firebase_auth构建失败问题
报错信息
C:\Users\Gabriel\Downloads\Projects\mcpark-update\mcpark\windows\flutter\ephemeral\cpp_client_wrapper\include\flutter\encodable_value.h(199,60): error C2665: 'std::variant<std::monostate,bool,int32_t,int64_t,double,std::string,std::vector<uint8_t,std::allocator<uint8_t>>,std::vector<int32_t,std::allocator<int>>,std::vector<int64_t,std::allocator<int64_t>>,std::vector<double,std::allocator<double>>,flutter::EncodableList,flutter::EncodableMap,flutter::CustomEncodableValue,std::vector<float,std::allocator<float>>>::variant': no overloaded function could convert all the argument types
已尝试的解决步骤
- 修改动态生成的
encodable_value.h文件:移除文件中std::variant声明里的std::vector<float,std::allocator<float>>,路径为:C:\Users\Gabriel\Downloads\Projects\mcpark-update\mcpark\windows\flutter\ephemeral\cpp_client_wrapper\include\flutter\encodable_value.h - 修改Flutter SDK内的
encodable_value.h文件:同样移除std::variant声明里的std::vector<float,std::allocator<float>>,路径为:C:\Users\Gabriel\flutter_windows_3.19.6-stable\flutter\bin\cache\artifacts\engine\windows-x64\cpp_client_wrapper\include\flutter\encodable_value.h - 强制启用C++17标准:在项目的
CMakeLists.txt中添加以下配置set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) - 降级firebase_auth版本:先后尝试了
^4.16.0和^5.3.4版本,问题未解决 - 重新安装依赖与工具:删除并重新安装Flutter SDK 3.19.6版本;确认Visual Studio 2022已安装MSVC v143构建工具、Windows 11 SDK(10.0.22621.0)和C++ CMake工具
问题说明
该问题仅在Windows平台构建时出现,移动端构建无异常。
环境详情
- Flutter: 3.19.6
- Dart: 3.3.4
- firebase_auth: 已尝试
^4.16.0和^5.3.4版本 - Visual Studio: 2022(已安装所需组件)
- OS: Windows 11
内容的提问来源于stack exchange,提问作者Gabriel Tavares
相关产品推荐
相关产品推荐

