[英]Compilation Error Flutter ArCore plugin "Type mismatch: inferred type is Activity? but Activity was expected"
I prepared everything in my flutter project for ArCore according to https://developers.google.com/ar/develop/java/enable-arcore?hl=en我根据https://developers.google.com/ar/develop/java/enable-arcore?hl=en在我的 flutter 项目中为 ArCore 准备了一切
(changes in AndroidManifest, build.gradle, gradle.properties). (AndroidManifest、build.gradle、gradle.properties 的变化)。 When trying to run the app I get the following error:
尝试运行该应用程序时出现以下错误:
e: C:\Flutter\flutter_windows_3.3.1-stable\flutter.pub-cache\hosted\pub.dartlang.org\arcore_flutter_plugin-0.0.11\android\src\main\kotlin\com\difrancescogianmarco\arcore_flutter_plugin\ArcoreFlutterPlugin.kt: (32, 74): Type mismatch: inferred type is Activity?
e: C:\Flutter\flutter_windows_3.3.1-stable\flutter.pub-cache\hosted\pub.dartlang.org\arcore_flutter_plugin-0.0.11\android\src\main\kotlin\com\difrancescogianmarco\arcore_flutter_plugin\ArcoreFlutterPlugin.kt : (32, 74): 类型不匹配:推断类型是 Activity? but Activity was expected
但活动是预期的
- What went wrong: Execution failed for task ':arcore_flutter_plugin:compileDebugKotlin'.
出了什么问题:任务 ':arcore_flutter_plugin:compileDebugKotlin' 执行失败。 Compilation error.
编译错误。 See log for more details
查看日志了解更多详情
I tried deleting "?"我试着删除“?” next to Activity in ArCoreView.kt line
在 ArCoreView.kt 行中的 Activity 旁边
override fun onActivityCreated(activity: Activity?, savedInstanceState: Bundle?) {
but it didn't help.但它没有帮助。 It looks like the problem is with the plugin.
看起来问题出在插件上。 What other changes in its code should help?
其代码的哪些其他更改应该有所帮助? Is any of its version working correctly?
它的任何版本是否正常工作? Or what other thing to change to make it work?
或者还有什么其他的改变才能让它发挥作用?
You are using flutter version 3.3.1 which is null safe version and arcore_flutter_plugin version is 0.0.11, which is not null safe plugin.您正在使用 flutter 版本 3.3.1,这是 null 安全版本,arcore_flutter_plugin 版本是 0.0.11,不是 null 安全插件。 please use null safe version.
请使用 null 安全版。
please use below version of arcore_flutter_plugin请使用以下版本的 arcore_flutter_plugin
arcore_flutter_plugin: ^0.1.0-null-safety.3 arcore_flutter_plugin: ^0.1.0-null-safety.3
The only solution that worked for me was downgrading flutter to last non null-safety version (2.10.5)唯一对我有用的解决方案是将 flutter 降级到最后一个非空安全版本 (2.10.5)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.