Flutter-无法将应用程序安装到模拟器

gajydyqb  于 2022-12-24  发布在  Flutter
关注(0)|答案(2)|浏览(177)

我有一个Flutter项目,以前运行在Flutter 2.2上。最近,我升级到Flutter 2.10,但无法在Android模拟器上运行应用程序。我按照https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects上的说明操作。我在Ubuntu上运行模拟器。
我所尝试的(从其他StackOverflow职位)没有工作在所有:

  • 正在重新启动模拟器
  • 删除依赖项(我删除了pubspec.yaml中的所有依赖项)
  • 接受Android SDK许可证
  • 使用Android Pie版本模拟器
  • 运行flutter clean
  • 在模拟器上卸载应用程序

flutter doctor显示没有问题。有时run进程在安装/构建APK时卡住,有时我得到'连接到服务协议时出错'。

✓  Built build/app/outputs/flutter-apk/app-debug.apk.
E/AndroidRuntime(10386): FATAL EXCEPTION: main
E/AndroidRuntime(10386): Process: com.app.example, PID: 10386
E/AndroidRuntime(10386): java.lang.NoSuchMethodError: No static method getMainExecutor(Landroid/content/Context;)Ljava/util/concurrent/Executor; in class Landroidx/core/content/ContextCompat; or its super classes (declaration of 'androidx.core.content.ContextCompat' appears in /data/app/com.app.example-pnJtFUSDIe4xWUHIPO1jNQ==/base.apk)
E/AndroidRuntime(10386):    at io.flutter.embedding.android.FlutterView.onAttachedToWindow(FlutterView.java:483)
E/AndroidRuntime(10386):    at android.view.View.dispatchAttachedToWindow(View.java:18347)
E/AndroidRuntime(10386):    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3397)
E/AndroidRuntime(10386):    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404)
E/AndroidRuntime(10386):    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404)
E/AndroidRuntime(10386):    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404)
E/AndroidRuntime(10386):    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1761)
E/AndroidRuntime(10386):    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1460)
E/AndroidRuntime(10386):    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7183)
E/AndroidRuntime(10386):    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:949)
E/AndroidRuntime(10386):    at android.view.Choreographer.doCallbacks(Choreographer.java:761)
E/AndroidRuntime(10386):    at android.view.Choreographer.doFrame(Choreographer.java:696)
E/AndroidRuntime(10386):    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935)
E/AndroidRuntime(10386):    at android.os.Handler.handleCallback(Handler.java:873)
E/AndroidRuntime(10386):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(10386):    at android.os.Looper.loop(Looper.java:193)
E/AndroidRuntime(10386):    at android.app.ActivityThread.main(ActivityThread.java:6669)
E/AndroidRuntime(10386):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(10386):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/AndroidRuntime(10386):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

我可以运行相同的代码(在同一个项目上)到网页浏览器。我可以运行相同的代码在模拟器上,如果它被复制到另一个新创建的项目是用Flutter 2.10创建的。我也复制了AndroidManifest.xmlbuild.gradle从新项目到旧项目,但也不工作。
任何解决方案或建议,我应该做什么来解决它。

kqlmhetl

kqlmhetl1#

看起来您仍然可以参考以前版本的android库com.android ...,最新的flutter使用androidX。
确保你没有任何

implementation 'com.android....`

在你的毕业档案里。

0lvr5msh

0lvr5msh2#

几个月来我一直有同样的问题。我什么都试过了,但还是没有结果。你们已经解决了吗?

相关问题