flutter 热修复_修复Flutter上的域/默认对错误

flutter 热修复

If you’re like me, you’ve been enjoying using Flutter to make some really great apps lately. One of the things about using such a cutting edge framework is that you’re bound to encounter some potentially weird issues…without knowing exactly how to fix it.

如果您像我一样,最近就喜欢使用Flutter制作一些非常出色的应用程序。 使用这种最先进的框架的一件事是,您必然会遇到一些潜在的奇怪问题……而又不知道确切的解决方法。

I just spent 4 hours on the domain/default pair issue. In your build log it looks like this:

我刚刚在domain/default对问题上花费了4个小时。 在您的构建日志中,它看起来像这样:

It’s not clear what is going wrong here. Looking up further in the build log gives us some more idea.

目前尚不清楚这里出了什么问题。 在构建日志中进一步查找为我们提供了更多思路。

App.framework/flutter_assets/ios/Flutter/App.framework/flutter_assets/
    App.framework/flutter_assets/ios/Flutter/App.framework/flutter_assets/buildtime/
    App.framework/flutter_assets/ios/Flutter/App.framework/flutter_assets/buildtime/assets/
    App.framework/flutter_assets/ios/Flutter/App.framework/flutter_assets/buildtime/assets/logo.png
    App.framework/flutter_assets/ios/Flutter/App.framework/flutter_assets/buildtime/assets/phone.png
    App.framework/flutter_assets/ios/Flutter/App.framework/flutter_assets/buildtime/assets/winkydude.json

Can you spot it? It’s the last line. For some reason, Flutter is trying to recursively add our assets folder into our build, which is making the build break with a totally unrelated and nonsensical error. This issue tracks the problem, with a wide array of potential fixed (like moving your assets folder elsewhere, checking if you have .env files in your project root), but none of them fixed it for me.

你能发现吗? 这是最后一行。 由于某种原因,Flutter试图将我们的assets文件夹递归添加到我们的构建中,这使构建因完全不相关且毫无意义的错误而中断。 该问题跟踪了该问题,并修复了许多潜在问题(例如,将资产文件夹移动到其他位置,检查项目根目录中是否有.env文件),但是它们都没有为我解决。

I hypothesised that this could be happening because of how I was including my assets. In my project, it looked like this:

我假设这可能是由于我将资产包括在内而发生的。 在我的项目中,它看起来像这样:

assets:
- winkydude.json
- assets/avatars/
- phone.png
- logo.png

The problem was with the bolded line — I was including a folder and figuring Flutter could just bring everything from that folder in recursively. I changed it to this, where I explicitly called out every single file that was in that folder.

问题在于粗体行–我当时包含一个文件夹,并且认为Flutter可以递归地携带该文件夹中的所有内容。 我将其更改为此,我在其中显式调出该文件夹中的每个文件。

assets:
- winkydude.json# - assets/avatars/
- phone.png
- logo.png
- assets/avatars/bike.json
- assets/avatars/coffeebiscuit.json
- assets/avatars/hearts.json
- assets/avatars/ice_cream.json
- assets/avatars/sheepcart.json
- assets/avatars/sheepcomputer.json
- assets/avatars/sheepoutrun.json
- assets/avatars/sheeprain.json
- assets/avatars/sheepswimming.json

And my build started working.

我的构建开始工作。

我不想命名资产目录中的每个文件 (I don’t want to name every file in my assets directory)

You probably should anyway, right? That way you get to see in your commits over time when specific files came and left your build. And you’re not just adding a bucket of files into your app.

无论如何你可能应该吧? 这样一来,您就可以在一段时间内看到特定文件何时离开并离开构建的提交。 而且,您不只是在应用程序中添加文件桶。

As I come across more ways of fixing this issue, I’ll update this article.

当我遇到更多解决此问题的方法时,将更新本文。

I hope this helps you! Comment if it does (or if it doesn’t). And happy Fluttering!

我希望这可以帮助你! 注释是否(如果不这样做)。 和快乐飘飘!

https://www.twitter.com/FlutterComm

https://www.twitter.com/FlutterComm

翻译自: https://medium.com/flutter-community/fixing-the-domain-default-pair-error-on-flutter-34abf3c8de81

flutter 热修复

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值