在模拟器上运行flutter app抛出Could not update files on device: HttpException异常

在mumu模拟器上运行flutter app,启动的时候闪退,日志如下:

I/OpenGLRenderer( 9665): Initialized EGL, version 1.4
D/        ( 9665): HostConnection::get() New Host Connection established 0xa0642dc0, tid 9708
D/        ( 9665): HostConnection::get() New Host Connection established 0xa067e620, tid 9683
W/EGL_emulation( 9665): eglSurfaceAttrib not implemented
W/OpenGLRenderer( 9665): Failed to set EGL_SWAP_BEHAVIOR on surface 0xadeb1480, error=EGL_SUCCESS
E/flutter ( 9665): [ERROR:flutter/shell/gpu/gpu_surface_gl.cc(64)] Failed to setup Skia Gr context.
F/libc    ( 9665): Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 9683 (1.gpu)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'OnePlus/OnePlus2/OnePlus2:6.0.1/MMB29M/1447841200:user/release-keys'
Revision: '0'
ABI: 'x86'
pid: 9665, tid: 9683, name: 1.gpu  >>> com.example.flutter_app <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
    eax 00000000  ebx a30f6bbc  ecx 00000000  edx 00000000
    esi b3b39960  edi a158a538
    xcs 00000073  xds 0000007b  xes 0000007b  xfs 0000003b  xss 0000007b
    eip a27e0b52  ebp a158a528  esp a158a4e0  flags 00210246
backtrace:
    #00 pc 01156b52  /data/app/com.example.flutter_app-1/lib/x86/libflutter.so (offset 0x10fb000)
    #01 pc 0115b662  /data/app/com.example.flutter_app-1/lib/x86/libflutter.so (offset 0x10fb000)
    #02 pc 01160012  /data/app/com.example.flutter_app-1/lib/x86/libflutter.so (offset 0x10fb000)
    #03 pc 01114729  /data/app/com.example.flutter_app-1/lib/x86/libflutter.so (offset 0x10fb000)
    #04 pc 01116ce8  /data/app/com.example.flutter_app-1/lib/x86/libflutter.so (offset 0x10fb000)
    #05 pc 01116c2a  /data/app/com.example.flutter_app-1/lib/x86/libflutter.so (offset 0x10fb000)
    #06 pc 0111d678  /data/app/com.example.flutter_app-1/lib/x86/libflutter.so (offset 0x10fb000)
    #07 pc 0111d6a6  /data/app/com.example.flutter_app-1/lib/x86/libflutter.so (offset 0x10fb000)
    #08 pc 00018fd2  /system/lib/libutils.so (_ZN7android20SimpleLooperCallback11handleEventEiiPv+32)
    #09 pc 0001afd9  /system/lib/libutils.so (_ZN7android6Looper9pollInnerEi+409)
    #10 pc 0001b327  /system/lib/libutils.so (_ZN7android6Looper8pollOnceEiPiS1_PPv+53)
    #11 pc 0000a1d1  /system/lib/libandroid.so (ALooper_pollOnce+96)
    #12 pc 0111d5b5  /data/app/com.example.flutter_app-1/lib/x86/libflutter.so (offset 0x10fb000)
    #13 pc 01116bd8  /data/app/com.example.flutter_app-1/lib/x86/libflutter.so (offset 0x10fb000)
    #14 pc 0111674a  /data/app/com.example.flutter_app-1/lib/x86/libflutter.so (offset 0x10fb000)
    #15 pc 0111accf  /data/app/com.example.flutter_app-1/lib/x86/libflutter.so (offset 0x10fb000)
    #16 pc 000811d1  /system/lib/libc.so (_ZL15__pthread_startPv+56)
    #17 pc 0002174e  /system/lib/libc.so (__start_thread+25)
    #18 pc 00016ea6  /system/lib/libc.so (__bionic_clone+70)
Tombstone written to: /data/tombstones/tombstone_01
Lost connection to device.
Could not update files on device: HttpException: Connection closed before full header was received, uri =
http://127.0.0.1:52250/eWzgEbUU3S4=/
Syncing files to device MuMu...

在终端执行 flutter run --enable-software-rendering即可,运行 flutter help run可以看出该参数的含义是:

Run your Flutter app on an attached device.

Usage: flutter run [arguments]
-h, --help                                   Print this usage information.
    --debug                                  Build a debug version of your app (default mode).
    --profile                                Build a version of your app specialized for performance profiling.
    --release                                Build a release version of your app.
    --flavor                                 Build a custom app flavor as defined by platform-specific build setup.
                                             Supports the use of product flavors in Android Gradle scripts, and the use
                                             of custom Xcode schemes.

    --trace-startup                          Trace application startup, then exit, saving the trace to a file.
    --verbose-system-logs                    Include verbose logging from the flutter engine.
    --route                                  Which route to load when running the app.
-t, --target=<path>                          The main entry-point file of the application, as run on the device.
                                             If the --target option is omitted, but a file name is provided on the
                                             command line, then that is used instead.
                                             (defaults to "lib\main.dart")

    --observatory-port                       Listen to the given port for an observatory debugger connection.
                                             Specifying port 0 (the default) will find a random free port.

    --[no-]pub                               Whether to run "flutter pub get" before executing this command.
                                             (defaults to on)

    --[no-]track-widget-creation             Track widget creation locations. This enables features such as the widget
                                             inspector. This parameter is only functional in debug mode (i.e. when
                                             compiling JIT, not AOT).

    --start-paused                           Start in a paused mode and wait for a debugger to connect.
    --enable-software-rendering              Enable rendering using the Skia software backend. This is useful when
                                             testing Flutter on emulators. By default, Flutter will attempt to either
                                             use OpenGL or Vulkan and fall back to software when neither is available.

    --skia-deterministic-rendering           When combined with --enable-software-rendering, provides 100% deterministic
                                             Skia rendering.

    --trace-skia                             Enable tracing of Skia code. This is useful when debugging the GPU thread.
                                             By default, Flutter will not log skia code.

    --trace-systrace                         Enable tracing to the system tracer. This is only useful on platforms where
                                             such a tracer is available (Android and Fuchsia).

    --dump-skp-on-shader-compilation         Automatically dump the skp that triggers new shader compilations. This is
                                             useful for wrting custom ShaderWarmUp to reduce jank. By default, this is
                                             not enabled to reduce the overhead. This is only available in profile or
                                             debug build.

    --[no-]await-first-frame-when-tracing    Whether to wait for the first frame when tracing startup
                                             ("--trace-startup"), or just dump the trace as soon as the application is
                                             running. The first frame is detected by looking for a Timeline event with
                                             the name "Rasterized first useful frame". By default, the widgets library's
                                             binding takes care of sending this event.
                                             (defaults to on)

    --[no-]use-test-fonts                    Enable (and default to) the "Ahem" font. This is a special font used in
                                             tests to remove any dependencies on the font metrics. It is enabled when
                                             you use "flutter test". Set this flag when running a test using "flutter
                                             run" for debugging purposes. This flag is only available when running in
                                             debug mode.

    --[no-]build                             If necessary, build the app before running.
                                             (defaults to on)

    --[no-]hot                               Run with support for hot reloading. Only available for debug mode. Not
                                             available with "--trace-startup".
                                             (defaults to on)

    --pid-file                               Specify a file to write the process id to. You can send SIGUSR1 to trigger
                                             a hot reload and SIGUSR2 to trigger a hot restart.

Run "flutter help" to see global options.

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
根据提供的引用内容,这个问题可能是由以下两个原因之一引起的: 1. 缺少字体文件 2. build-tools版本与项目的版本不一致 以下是解决这两个问题的方法: 1. 如果缺少字体文件,请按照以下步骤将字体文件添加到您的项目中: - 将字体文件复制到您的项目的android/app/src/main/assets/fonts/目录下。 - 在您的项目的android/app/build.gradle文件中添加以下代码: ```gradle project.ext.react = [ ... extraPackagerArgs: ["--assetExts", "ttf"] ] ``` - 在您的项目的android/app/src/main/java/com/yourproject/MainApplication.java文件中添加以下代码: ```java package com.yourproject; import android.graphics.Typeface; import com.facebook.react.ReactApplication; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.react.shell.MainReactPackage; import com.facebook.soloader.SoLoader; import java.util.Arrays; import java.util.List; public class MainApplication extends Application implements ReactApplication { private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { @Override public boolean getUseDeveloperSupport() { return BuildConfig.DEBUG; } @Override protected List<ReactPackage> getPackages() { return Arrays.<ReactPackage>asList( new MainReactPackage() ); } @Override protected String getJSMainModuleName() { return "index"; } @Override protected String getJSBundleFile() { return "assets://index.android.bundle"; } @Override protected String getBundleAssetName() { return "index.android.bundle"; } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TypefaceUtil.overrideFont(getApplicationContext(), "SERIF", "fonts/YourFont.ttf"); } }; @Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; } @Override public void onCreate() { super.onCreate(); SoLoader.init(this, /* native exopackage */ false); } } ``` 2. 如果build-tools版本与项目的版本不一致,请按照以下步骤解决: - 运行flutter doctor -v命令,查看您的Flutter环境是否正常。 - 确保您的项目的build.gradle文件中的buildToolsVersion与您的Android SDK中安装的build-tools版本相同。 - 如果您的Android SDK中没有安装所需的build-tools版本,请打开Android Studio并安装它们。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

释汐宇辰

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值