简体   繁体   English

Flutter 应用程序打开,但卡在启动画面上

[英]Flutter app opens, but is stuck on splash-screen

When I built my iOS app, it opened perfectly in the simulator on my Macbook.当我构建我的 iOS 应用程序时,它在我的 Macbook 上的模拟器中完美打开。 When I publish the app on the itunes store, the app does not work anymore.当我在 iTunes 商店发布该应用程序时,该应用程序不再运行。 The splashscreen is shown, but stays on the screen.启动画面显示,但停留在屏幕上。

Solution for me:对我的解决方案:

1) updated my iOS toolchain with flutter doctor 1) 用 flutter doctor 更新了我的 iOS 工具链

2) flutter clean 2) flutter clean

3) flutter build ios --release in the terminal 3) flutter build ios --release在终端

4) Archive in Xcode 4) 在 Xcode 中存档

我通过删除project_root/ios/Pods/ & project_root/ios/Podfile.lock并在flutter clean & flutter build ios --release之后再次运行pod install解决这个flutter build ios --release

I tried various solutions.我尝试了各种解决方案。 But finally i found out issue was version of my android studio(ide used for development for flutter, in my case).但最后我发现问题是我的 android studio 版本(在我的例子中用于开发 flutter 的 ide)。 I updated my version to 3.2.1 and then followed instructions to run in xcode and it worked in my case.我将我的版本更新到 3.2.1,然后按照说明在 xcode 中运行,它在我的情况下工作。 Hope it helps!希望能帮助到你!

I added WidgetsFlutterBinding.ensureInitialized() to the main page.我将WidgetsFlutterBinding.ensureInitialized()添加到主页面。

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(MyApp());
}

I had this problem with an android build of an app that uses multiple flavors, but in the end it turned out I was simply using the wrong APK file.我在使用多种风格的应用程序的 android 版本中遇到了这个问题,但最终我发现我只是使用了错误的 APK 文件。

So the build created 3 apk files eg.所以构建创建了 3 个 apk 文件,例如。

myapp.apk
myapp-test-debug.apk
myapp-test-release.apk

My assumption was to use the test-release.apk which got the app stuck on the splash screen.我的假设是使用test-release.apk使应用程序卡在启动屏幕上。 Using the myapp.apk did not have this problem.使用myapp.apk没有这个问题。

Bit of a facepalm moment for myself but maybe this helps someone else looking for an answer!对我自己来说有点失控,但也许这有助于其他人寻找答案!

I face the same issues, and I finally found that the root of the problem is the setting of workspace of xcode,when i change the workspace settings from legacy build system to new build system,the bug disappear .我遇到了同样的问题,我终于发现问题的根源是 xcode 的工作区设置,当我将工作区设置从旧构建系统更改为新构建系统时,错误消失了。 hope can help you.希望能帮到你。

Maybe Podfile is out of date.也许 Podfile 已经过时了。

Solution for me:对我的解决方案:

  1. Remove Pobfile folder and Pobfile.lock direction: "your_flutter_project/ios/"删除 Pobfile 文件夹和 Pobfile.lock 方向:“your_flutter_project/ios/”
  2. Run flutter clean运行flutter clean
  3. Run flutter pub get运行flutter pub get
  4. Run flutter build ios运行flutter build ios

Hope this helpful.希望这有帮助。

If non of the above solutions work for you on ios, Try this.如果以上解决方案都不适用于您的 ios,请尝试此操作。 In xcode under Targets > General.在 xcode 下的 Targets > General。 Set Main interface to Main and set luanch screen file to LaunchScreen.将主界面设置为 Main,将 luanch 屏幕文件设置为 LaunchScreen。

This worked for me on IOS.这在 IOS 上对我有用。

Add android:allowBackup="false" tag inside your <application> object in your app manifest在应用程序清单中的<application>对象中添加android:allowBackup="false"标签

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM