Flutter应用程序启动时崩溃

7
我的flutter应用在安卓启动时崩溃了。 我已经移除了google_sign_in和location包,现在似乎它可以工作了。根据我的阅读理解,我相信这些包依赖于不同版本的谷歌播放服务; 然而,我对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.access$1400(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的依赖,启动时就不会崩溃了。我猜想我需要设置location和google_sign_in的版本或找到一种设置它们的Google Play依赖关系的方法,但我不确定如何做。

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

 buildscript {
    repositories {
        google()
        jcenter()
    }

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

你更新了Gradle文件吗? - diegoveloper
你能在问题中添加更多的日志吗? - diegoveloper
已添加我的 Android build.gradle 文件。除了运行 flutter run 之外,我需要运行其他东西来更新它们吗? - Cody Short
更新了更多的调试信息。 - Cody Short
2个回答

3
请将以下行添加到您的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

已将其添加到 android/app/build.gradle,但仍然崩溃。 - Cody Short
清除Flutter缓存并重试,您能否检查是否有任何特定的库生成了崩溃? - diegoveloper
运行 flutter clean。尝试了不同的包组合...可以确认只要有这三者之一以上的两个,就会发生此问题:google_sign_in、firebase_auth 和 location。 - Cody Short
我该怎么做?谢谢! - Cody Short
我的意思是,在你的pubspec文件中,将这个:firebase_auth: 0.5.4 改成 firebase_auth: 0.5.18,然后在命令行中尝试flutter clean,接着flutter packages get,最后尝试运行。 - diegoveloper
1
我应该知道的。我所遵循的方法使用了旧版本。我按照那个方法做了,现在一切看起来都很好。谢谢! - Cody Short

1
请在您的xml文件中添加以下内容:<meta-data android:name="flutterEmbedding" android:value="2" />。这将使其看起来像这样:`

<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>

`


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接