先說一下報錯Flutter版本:Stable channel v1.12.13+hotfix.5
報錯問題同:
Running "flutter pub get" in push_plugin... 0.2s
Running "flutter pub get" in example... 0.3s
Couldn't read file LocalFile: '/Users/kamy/project_flutter/push_plugin/android/src/main/kotlin/com/bob/push/plugin/PushPlugin.kt' even though it exists. Please verify that this file has read permission and try again.
首先我的插件是java開發的,所以網上移動xxx.kt到kotlin文件中是行不通的。
官方Issue上也有人在提問,這是估計一個官方的bug,估計會在下一個版本解決(新語言總要經歷這些):
https://github.com/flutter/flutter/issues/47933
我的解決辦法也很簡單,那就是回退版本……回退到上一個版本v1.9.1+hotfix.6即可解決。
如果不想回退解決可以嘗試用kotlin編寫插件的***Plugin類來嘗試是否可以解決。