迁移到 Apple M1 后,我的应用程序不再启动

Posted

技术标签:

【中文标题】迁移到 Apple M1 后,我的应用程序不再启动【英文标题】:After migrating to an Apple M1, my app doesn't start anymore 【发布时间】:2021-10-24 09:00:00 【问题描述】:

1 年前我开发了一个应用程序。我发布的最新更新是 2 个月前。从那以后,我从 MacBook Pro 2017 换成了 Apple Air M1。 今天,我想对这个应用程序进行一些更新,所以我克隆了我的私人 Git 存储库,安装了所需的工具(Flutter、android Studio ......) 我无法启动该应用程序。许多开发人员似乎都遇到了这个问题,flutter clean + flutter get 命令似乎可以解决这个问题,但对我来说不是。

我运行了一些命令,这里是日志:

flutter run -d emulator-5554 --verbose 命令:

/opt/homebrew/Caskroom/flutter/2.2.3/flutter/.pub-cache/hosted/pub.dartlang.org/chewie-0.9.10/lib/src/chewie_player.dart:83:7: Error: No named
parameter with the name 'resizeToAvoidBottomPadding'.
resizeToAvoidBottomPadding: false,
^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/homebrew/Caskroom/flutter/2.2.3/flutter/packages/flutter/lib/src/material/scaffold.dart:1466:9: Context: Found this candidate, but the arguments
don't match.const Scaffold(
                  ^^^^^^^^ 
/opt/homebrew/Caskroom/flutter/2.2.3/flutter/.pub-cache/hosted/pub.dartlang.org/chewie-0.9.10/lib/src/chewie_player.dart:276:17: Error: The method
'inheritFromWidgetOfExactType' isn't defined for the class 'BuildContext'.
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart'
('/opt/homebrew/Caskroom/flutter/2.2.3/flutter/packages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'inheritFromWidgetOfExactType'.
context.inheritFromWidgetOfExactType(_ChewieControllerProvider)
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/homebrew/Caskroom/flutter/2.2.3/flutter/.pub-cache/hosted/pub.dartlang.org/chewie_audio-1.0.0+1/lib/src/chewie_player.dart:101:17: Error: The
method 'inheritFromWidgetOfExactType' isn't defined for the class 'BuildContext'.
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart'
('/opt/homebrew/Caskroom/flutter/2.2.3/flutter/packages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'inheritFromWidgetOfExactType'.
context.inheritFromWidgetOfExactType(_ChewieAudioControllerProvider)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Persisting file store
Done persisting file store
Target kernel_snapshot failed: Exception
#0 KernelSnapshot.build (package:flutter_tools/src/build_system/targets/common.dart:291:7)
<asynchronous suspension>
#1 _BuildInstance._invokeInternal (package:flutter_tools/src/build_system/build_system.dart:828:9)
<asynchronous suspension>
#2 Future.wait.<anonymous closure> (dart:async/future.dart)
<asynchronous suspension>
#3 _BuildInstance.invokeTarget (package:flutter_tools/src/build_system/build_system.dart:766:32)
<asynchronous suspension>
#4      FlutterBuildSystem.build (package:flutter_tools/src/build_system/build_system.dart:595:16)
<asynchronous suspension>
#5      AssembleCommand.runCommand (package:flutter_tools/src/commands/assemble.dart:318:32)
<asynchronous suspension>
#6      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1043:27)
<asynchronous suspension>
#7      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#8      CommandRunner.runCommand (package:args/command_runner.dart:196:13)
<asynchronous suspension>
#9      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:284:9) <asynchronous suspension>
#10     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19) <asynchronous suspension>
#11     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:232:5) <asynchronous suspension>
#12     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9) <asynchronous suspension>
#13     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19) <asynchronous suspension>
#14     main (package:flutter_tools/executable.dart:91:3) <asynchronous suspension>
"flutter assemble" took 12 390ms.
 
#0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
#1      AssembleCommand.runCommand (package:flutter_tools/src/commands/assemble.dart:335:7) <asynchronous suspension>
#2      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1043:27) <asynchronous suspension>
#3      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#4      CommandRunner.runCommand (package:args/command_runner.dart:196:13) <asynchronous suspension>
#5      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:284:9) <asynchronous suspension>
#6      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19) <asynchronous suspension>
#7      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:232:5) <asynchronous suspension>
#8 run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9) <asynchronous suspension>
#9 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19) <asynchronous suspension>
#10 main (package:flutter_tools/executable.dart:91:3) <asynchronous suspension> 
ensureAnalyticsSent: 102ms
Running shutdown hooks
Shutdown hooks complete
exiting with code 1
> Task :app:compileFlutterBuildDebug FAILED
1 actionable task: 1 executed
FAILURE: Build failed with an exception.
* Where:
Script '/opt/homebrew/Caskroom/flutter/2.2.3/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1035
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command '/opt/homebrew/Caskroom/flutter/2.2.3/flutter/bin/flutter'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 15s
Running Gradle task 'assembleDebug'... (completed in 16,0s)
Exception: Gradle task assembleDebug failed with exit code 1
 "flutter run" took 18 686ms.
 
#0 throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
#1 RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:663:9)
<asynchronous suspension>
#2 FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1043:27) <asynchronous suspension>
#3 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19) <asynchronous suspension>
#4      CommandRunner.runCommand (package:args/command_runner.dart:196:13) <asynchronous suspension>
#5      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:284:9) <asynchronous suspension>
#6      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19) <asynchronous suspension>
#7      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:232:5) <asynchronous suspension>
#8      run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9) <asynchronous suspension>
#9      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19) <asynchronous suspension>
#10     main (package:flutter_tools/executable.dart:91:3) <asynchronous suspension>
           
           
ensureAnalyticsSent: 91ms
Running shutdown hooks
Shutdown hooks complete
exiting with code 1

flutter doctor -v 命令:

[✓] Flutter (Channel stable, 2.2.3, on macOS 11.4 20F71 darwin-arm, locale fr-FR)
    • Flutter version 2.2.3 at /opt/homebrew/Caskroom/flutter/2.2.3/flutter
    • Framework revision f4abaa0735 (il y a 8 semaines), 2021-07-01 12:46:11 -0700
    • Engine revision 241c87ad80
    • Dart version 2.13.4

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/kamil.hammouche/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[✓] Xcode - develop for ios and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.5.1, Build version 12E507
    • CocoaPods version 1.10.2

[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Android Studio (version 2020.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      ???? https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      ???? https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[✓] Connected device (1 available)
    • sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 12 (API 31) (emulator)

! Doctor found issues in 1 category.

是否有人遇到过这个问题并知道如何解决它?

最好的问候,

【问题讨论】:

尝试更新你的依赖。 我已经将它们升级到最新的主要更新 您能否提供哪些代码可能会在您的项目中出现这些错误?你能提供吗?此外,通过您的日志显示后可能会出现咀嚼依赖错误和一些语法错误。 chewie 似乎遇到了空安全问题。您可以使用dart pub outdated --mode=null-safety 来检查您的包裹的状态 @SamChan 使用这个命令让它工作了,非常感谢! 【参考方案1】:

通过命令“adb devices”检查您的可用设备,如果显示 adb 无法识别,则添加用户变量 PATH: %USERPROFILE%\AppData\Local\Android\sdk\platform-tools 并重启 cmd

【讨论】:

【参考方案2】:

删除 gradle 缓存对我有帮助,您可以在此处找到步骤 How to clear gradle cache?

然后运行“flutter clean”和“flutter pub get”

【讨论】:

【参考方案3】:

你有谷歌浏览器吗? 看来您遇到了谷歌浏览器的问题。 欲了解更多信息..这是一个链接检查出来...... https://***.com/a/66665750/16558933[Cannot找铬]1

【讨论】:

我不是为网络开发的,所以我不需要谷歌浏览器 我正在为移动端开发,所以我不会在网络上编译 亲爱的,你没有得到我...谷歌浏览器是颤振的必备品..无论您是否在网络上编译... 我刚刚为 iOS 和 Android 构建了没有安装 Google Chrome 的版本。 这个答案将修复flutter doctor 输出,但它不能解决在移动设备上运行代码的实际问题

以上是关于迁移到 Apple M1 后,我的应用程序不再启动的主要内容,如果未能解决你的问题,请参考以下文章

Mac 系统快速迁移记录(M1 Max)

iOS 模拟器在 Apple M1 上滚动太快

<t:inputFileUpload> 将 JSF 1.2 迁移到 JSF 2.2 后不再工作

已解决Apple Mac M1 docker环境下nacos无法启动

迁移到 M1 Mac 后在 iOS 上运行 Flutter App 时出错

迁移到 ASP.NET 3.1 - 从登录控制器路由到 Razor 页面主页索引页面不再工作