当前位置:   article > 正文

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

flutter热修复线上ios

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.

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

  1. App.framework/flutter_assets/ios/Flutter/App.framework/flutter_assets/
  2. App.framework/flutter_assets/ios/Flutter/App.framework/flutter_assets/buildtime/
  3. App.framework/flutter_assets/ios/Flutter/App.framework/flutter_assets/buildtime/assets/
  4. App.framework/flutter_assets/ios/Flutter/App.framework/flutter_assets/buildtime/assets/logo.png
  5. App.framework/flutter_assets/ios/Flutter/App.framework/flutter_assets/buildtime/assets/phone.png
  6. 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 热修复

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/708302
推荐阅读
相关标签
  

闽ICP备14008679号