Flutter 更新后本地插件报错:Couldn't read file LocalFile: "***/***.kt" even though it exists!

先说一下报错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类来尝试是否可以解决。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
直接本地的 .aar 文件依赖项不支持构建 AAR。由于任何本地 .aar 文件依赖项的类和 Android 资源不会打包在生成的 AAR 中,因此生成的 AAR 将无法使用。在这种情况下,Android Gradle 插件的早期版本也会生成损坏的 AAR(尽管不会抛出此错误)。如果您的 Flutter 项目中使用了本地的 .aar 文件依赖项,那么您需要将其转换为 Maven 依赖项,或者将其打包为本地 Maven 存储库中的库。您可以使用以下步骤解决此问题: 1. 将本地的 .aar 文件依赖项转换为 Maven 依赖项。您可以使用以下命令将其转换为 Maven 依赖项: ``` ./gradlew :<module-name>:uploadArchives ``` 然后,您可以在项目的 build.gradle 文件中添加以下 Maven 依赖项: ``` repositories { mavenLocal() // other repositories } dependencies { implementation '<group-id>:<artifact-id>:<version>' // other dependencies } ``` 2. 将本地的 .aar 文件依赖项打包为本地 Maven 存储库中的库。您可以使用以下步骤将其打包为本地 Maven 存储库中的库: a. 在项目的 build.gradle 文件中添加以下 Maven 存储库: ``` repositories { mavenLocal() // other repositories } ``` b. 在本地 Maven 存储库中创建一个新的目录,并将 .aar 文件复制到该目录中。 c. 在 .aar 文件所在的目录中创建一个新的 build.gradle 文件,并添加以下内容: ``` apply plugin: 'maven' group = '<group-id>' version = '<version>' artifactId = '<artifact-id>' repositories { mavenLocal() } uploadArchives { repositories { mavenDeployer { repository(url: "file://${System.properties['user.home']}/.m2/repository") } } } ``` d. 在 .aar 文件所在的目录中运行以下命令: ``` ./gradlew uploadArchives ``` 然后,您可以在项目的 build.gradle 文件中添加以下 Maven 依赖项: ``` repositories { mavenLocal() // other repositories } dependencies { implementation '<group-id>:<artifact-id>:<version>' // other dependencies } ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

倚栏静望

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值