Flutter 应用程序在启动时崩溃

Flutter App Crashes on Startup

我的 Flutter 应用程序在 android 启动时崩溃。我拿走了 google_sign_in 和位置包。现在它似乎工作。根据我正在阅读的内容,我认为这与这些包有关,具体取决于 google 播放服务的不同版本;但是,我对 flutter 有点陌生,我不知道如何解决这个问题。

我得到一个堆栈跟踪,其中包含与此类似的错误消息:

    08-17 09:56:13.668 1740-1745/? E/MP-Decision: num online cores: 2 reqd : 4 available : 4 rq_depth:7.700000 hotplug_avg_load_dw: 184
    UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:0.000000
    UP cpu:2 core_idx:2 Nw:2.700000 Tw:90 total_time_up:91.000000
    UP cpu:3 core_idx:3 Nw:3.500000 Tw:90 total_time_up:91.000000
08-17 09:56:13.838 6267-6273/? E/jdwp: Failed sending reply to debugger: Bad file number
08-17 09:56:14.069 1740-1745/? E/MP-Decision: num online cores: 4 reqd : 1 available : 4 rq_depth:0.600000 hotplug_avg_load_dw: 21
    DOWN cpu:3 core_idx:3 Ns:3.100000 Ts:240 total_time_down:245.000000
    DOWN cpu:2 core_idx:2 Ns:2.100000 Ts:240 total_time_down:245.000000
    DOWN cpu:1 core_idx:1 Ns:1.100000 Ts:190 total_time_down:196.000000
08-17 09:56:14.319 1740-1745/? E/MP-Decision: num online cores: 1 reqd : 2 available : 4 rq_depth:1.700000 hotplug_avg_load_dw: 67
    UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:0.000000
08-17 09:56:14.439 5011-5025/? E/QcrilMsgTunnelSocket: IOExceptionjava.io.IOException: No such file or directoryReason: No such file or directory
08-17 09:56:14.819 1740-1745/? E/MP-Decision: num online cores: 2 reqd : 1 available : 4 rq_depth:1.000000 hotplug_avg_load_dw: 15
    DOWN cpu:1 core_idx:1 Ns:1.100000 Ts:190 total_time_down:245.000000
08-17 09:56:15.120 1740-1745/? E/MP-Decision: num online cores: 1 reqd : 2 available : 4 rq_depth:1.300000 hotplug_avg_load_dw: 67
    UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:0.000000
08-17 09:56:15.520 1740-1745/? E/MP-Decision: num online cores: 2 reqd : 3 available : 4 rq_depth:4.800000 hotplug_avg_load_dw: 94
    UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:0.000000
    UP cpu:2 core_idx:2 Nw:2.700000 Tw:90 total_time_up:98.000000
08-17 09:56:15.550 6332-6332/com.jeepapp.jeepapp E/AndroidRuntime: FATAL EXCEPTION: main
    java.lang.NoClassDefFoundError: com.google.android.gms.common.internal.zzbq
        at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
        at android.app.ActivityThread.installProvider(ActivityThread.java:4995)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:4608)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4548)
        at android.app.ActivityThread.access00(ActivityThread.java:151)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1341)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:5293)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
        at dalvik.system.NativeStart.main(Native Method)
08-17 09:56:15.570 1740-1745/? E/MP-Decision: num online cores: 3 reqd : 4 available : 4 rq_depth:4.300000 hotplug_avg_load_dw: 186
    UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:0.000000
    UP cpu:2 core_idx:2 Nw:2.700000 Tw:90 total_time_up:0.000000
    UP cpu:3 core_idx:3 Nw:3.500000 Tw:90 total_time_up:95.000000
08-17 09:56:15.820 1740-1745/? E/MP-Decision: num online cores: 4 reqd : 2 available : 4 rq_depth:1.000000 hotplug_avg_load_dw: 77
    DOWN cpu:3 core_idx:3 Ns:3.100000 Ts:240 total_time_down:242.000000
    DOWN cpu:2 core_idx:2 Ns:2.100000 Ts:240 total_time_down:242.000000
08-17 09:56:15.900 726-812/? E/android.os.Debug: !@Dumpstate > sdumpstate -k -t -z -d -o /data/log/dumpstate_app_error
08-17 09:56:15.920 1740-1745/? E/MP-Decision: num online cores: 2 reqd : 3 available : 4 rq_depth:3.300000 hotplug_avg_load_dw: 89
    UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:0.000000
    UP cpu:2 core_idx:2 Nw:2.700000 Tw:90 total_time_up:92.000000
08-17 09:56:16.371 1740-1745/? E/MP-Decision: num online cores: 3 reqd : 2 available : 4 rq_depth:2.000000 hotplug_avg_load_dw: 30
    DOWN cpu:2 core_idx:2 Ns:2.100000 Ts:240 total_time_down:245.000000
08-17 09:56:16.471 1740-1745/? E/MP-Decision: num online cores: 2 reqd : 1 available : 4 rq_depth:0.300000 hotplug_avg_load_dw: 17
    DOWN cpu:1 core_idx:1 Ns:1.100000 Ts:190 total_time_down:96.000000
08-17 09:56:17.182 1740-1745/? E/MP-Decision: num online cores: 1 reqd : 2 available : 4 rq_depth:0.000000 hotplug_avg_load_dw: 52
    UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:0.000000
08-17 09:56:18.112 6384-6384/? E/QSEECOMAPI:: Error::Failed to open /dev/qseecom device
08-17 09:56:18.112 6384-6384/? E/QSEECOMAPI:: Error::Failed to open /dev/qseecom device
08-17 09:56:18.112 6384-6384/? E/QSEECOMAPI:: Error::Failed to open /dev/qseecom device
08-17 09:56:18.112 6384-6384/? E/QSEECOMAPI:: Error::Failed to open /dev/qseecom device
08-17 09:56:18.112 6384-6384/? E/QSEECOMAPI:: Error::Failed to open /dev/qseecom device
08-17 09:56:18.213 1740-1745/? E/MP-Decision: num online cores: 2 reqd : 1 available : 4 rq_depth:1.000000 hotplug_avg_load_dw: 26
    DOWN cpu:1 core_idx:1 Ns:1.100000 Ts:190 total_time_down:245.000000
08-17 09:56:18.453 5011-5025/? E/QcrilMsgTunnelSocket: IOExceptionjava.io.IOException: No such file or directoryReason: No such file or directory
08-17 09:56:18.663 1740-1745/? E/MP-Decision: num online cores: 1 reqd : 3 available : 4 rq_depth:5.800000 hotplug_avg_load_dw: 69
    UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:147.000000
    UP cpu:2 core_idx:2 Nw:2.700000 Tw:90 total_time_up:147.000000
08-17 09:56:19.013 1740-1745/? E/MP-Decision: num online cores: 3 reqd : 4 available : 4 rq_depth:3.500000 hotplug_avg_load_dw: 107
    UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:0.000000
    UP cpu:2 core_idx:2 Nw:2.700000 Tw:90 total_time_up:0.000000
    UP cpu:3 core_idx:3 Nw:3.500000 Tw:90 total_time_up:98.000000
08-17 09:56:19.264 1740-1745/? E/MP-Decision: num online cores: 4 reqd : 2 available : 4 rq_depth:1.300000 hotplug_avg_load_dw: 91
    DOWN cpu:3 core_idx:3 Ns:3.100000 Ts:240 total_time_down:242.000000
    DOWN cpu:2 core_idx:2 Ns:2.100000 Ts:240 total_time_down:242.000000
08-17 09:56:19.364 1740-1745/? E/MP-Decision: num online cores: 2 reqd : 3 available : 4 rq_depth:4.800000 hotplug_avg_load_dw: 90
    UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:0.000000
    UP cpu:2 core_idx:2 Nw:2.700000 Tw:90 total_time_up:92.000000
08-17 09:56:19.774 1740-1745/? E/MP-Decision: num online cores: 3 reqd : 2 available : 4 rq_depth:0.000000 hotplug_avg_load_dw: 133
    DOWN cpu:2 core_idx:2 Ns:2.100000 Ts:240 total_time_down:396.000000
08-17 09:56:20.265 1740-1745/? E/MP-Decision: num online cores: 2 reqd : 1 available : 4 rq_depth:0.500000 hotplug_avg_load_dw: 24
    DOWN cpu:1 core_idx:1 Ns:1.100000 Ts:190 total_time_down:196.000000
08-17 09:56:22.487 5011-5025/? E/QcrilMsgTunnelSocket: IOExceptionjava.io.IOException: No such file or directoryReason: No such file or directory
08-17 09:56:22.737 1740-1745/? E/MP-Decision: num online cores: 1 reqd : 3 available : 4 rq_depth:15.300000 hotplug_avg_load_dw: 56
    UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:142.000000
    UP cpu:2 core_idx:2 Nw:2.700000 Tw:90 total_time_up:142.000000
08-17 09:56:22.787 1740-1745/? E/MP-Decision: num online cores: 3 reqd : 4 available : 4 rq_depth:8.900000 hotplug_avg_load_dw: 217
    UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:0.000000
    UP cpu:2 core_idx:2 Nw:2.700000 Tw:90 total_time_up:0.000000
    UP cpu:3 core_idx:3 Nw:3.500000 Tw:90 total_time_up:186.000000

此外,让您了解一下我的 pubspec.yaml:

dependencies:
  flutter:
    sdk: flutter
  flutter_map:
  location:
  google_sign_in:
  firebase_auth: 0.5.4

一旦我摆脱了 google_sign_in 和位置依赖性,它就不再在启动时崩溃。我猜我需要设置 location 和 google_sign_in 的版本,或者找到一种方法来设置它们的 google 播放依赖性,但我不确定该怎么做。

此外,我在 build.gradle 的 android 文件夹中有以下内容:

 buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.google.gms:google-services:3.2.1'
    }
}

app/build.gradle 文件的末尾添加这些行

 apply plugin: 'com.google.gms.google-services'

 configurations.all {
    resolutionStrategy {
        force 'com.google.android.gms:play-services-location:15.0.0'
     }
 }

更新您的 firebase_auth 依赖项:

firebase_auth: 0.5.18

尝试添加

<meta-data android:name="flutterEmbedding" android:value="2" />

到您的 xml 文件。
这将使它看起来像这样 `

<application
    android:name="io.flutter.app.FlutterApplication"
    android:label="gscwa"
    android:icon="@mipmap/ic_launcher">
    <activity
        android:name=".MainActivity"
        android:launchMode="singleTop"
        android:theme="@style/LaunchTheme"
        android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
        android:hardwareAccelerated="true"
        android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
    <!-- Don't delete the meta-data below.
         This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
    <meta-data
        android:name="flutterEmbedding"
        android:value="2" />
</application>

`