【问题标题】:Android Flutter app crashed during stratupAndroid Flutter 应用程序在启动期间崩溃
【发布时间】:2019-09-08 21:46:07
【问题描述】:

我使用这个 fit_kit(https://pub.dev/packages/fit_kit#-readme-tab-) for Flutter 从 iOS 和 Android 获取健康数据,iOS 部分似乎工作得很好,而 Android 应用程序在启动时总是崩溃。我已经在 Google Console 和 Firebase 上注册了该应用程序。

这是flutter run -verbose的详细说明

                   nin.RevocationBoundService" (Raw:
                   "com.google.android.gms.auth.api.signin.RevocationBoundServic
                   e")
                   A:
                   android:permission(0x01010006)="com.google.android.gms.auth.a
                   pi.signin.permission.REVOCATION_NOTIFICATION" (Raw:
                   "com.google.android.gms.auth.api.signin.permission.REVOCATION
                   _NOTIFICATION")
                   A: android:exported(0x01010010)=(type 0x12)0xffffffff
                 E: service (line=69)
                   A:
                   android:name(0x01010003)="com.google.firebase.components.Comp
                   onentDiscoveryService" (Raw:
                   "com.google.firebase.components.ComponentDiscoveryService")
                   A: android:exported(0x01010010)=(type 0x12)0x0
                   E: meta-data (line=72)
                     A:
                     android:name(0x01010003)="com.google.firebase.components:co
                     m.google.firebase.analytics.connector.internal.AnalyticsCon
                     nectorRegistrar" (Raw:
                     "com.google.firebase.components:com.google.firebase.analyti
                     cs.connector.internal.AnalyticsConnectorRegistrar")
                     A:
                     android:value(0x01010024)="com.google.firebase.components.C
                     omponentRegistrar" (Raw:
                     "com.google.firebase.components.ComponentRegistrar")
                   E: meta-data (line=75)
                     A:
                     android:name(0x01010003)="com.google.firebase.components:co
                     m.google.firebase.iid.Registrar" (Raw:
                     "com.google.firebase.components:com.google.firebase.iid.Reg
                     istrar")
                     A:
                     android:value(0x01010024)="com.google.firebase.components.C
                     omponentRegistrar" (Raw:
                     "com.google.firebase.components.ComponentRegistrar")
                 E: receiver (line=80)
                   A:
                   android:name(0x01010003)="com.google.firebase.iid.FirebaseIns
                   tanceIdReceiver" (Raw:
                   "com.google.firebase.iid.FirebaseInstanceIdReceiver")
                   A:
                   android:permission(0x01010006)="com.google.android.c2dm.permi
                   ssion.SEND" (Raw: "com.google.android.c2dm.permission.SEND")
                   A: android:exported(0x01010010)=(type 0x12)0xffffffff
                   E: intent-filter (line=84)
                     E: action (line=85)
                       A:
                       android:name(0x01010003)="com.google.android.c2dm.intent.
                       RECEIVE" (Raw: "com.google.android.c2dm.intent.RECEIVE")
                 E: activity (line=89)
                   A: android:theme(0x01010000)=@0x1030010
                   A:
                   android:name(0x01010003)="com.google.android.gms.common.api.G
                   oogleApiActivity" (Raw:
                   "com.google.android.gms.common.api.GoogleApiActivity")
                   A: android:exported(0x01010010)=(type 0x12)0x0
                 E: receiver (line=94)
                   A:
                   android:name(0x01010003)="com.google.android.gms.measurement.
                   AppMeasurementReceiver" (Raw:
                   "com.google.android.gms.measurement.AppMeasurementReceiver")
                   A: android:enabled(0x0101000e)=(type 0x12)0xffffffff
                   A: android:exported(0x01010010)=(type 0x12)0x0
                 E: receiver (line=99)
                   A:
                   android:name(0x01010003)="com.google.android.gms.measurement.
                   AppMeasurementInstallReferrerReceiver" (Raw:
                   "com.google.android.gms.measurement.AppMeasurementInstallRefe
                   rrerReceiver")
                   A:
                   android:permission(0x01010006)="android.permission.INSTALL_PA
                   CKAGES" (Raw: "android.permission.INSTALL_PACKAGES")
                   A: android:enabled(0x0101000e)=(type 0x12)0xffffffff
                   A: android:exported(0x01010010)=(type 0x12)0xffffffff
                   E: intent-filter (line=104)
                     E: action (line=105)
                       A:
                       android:name(0x01010003)="com.android.vending.INSTALL_REF
                       ERRER" (Raw: "com.android.vending.INSTALL_REFERRER")
                 E: service (line=109)
                   A:
                   android:name(0x01010003)="com.google.android.gms.measurement.
                   AppMeasurementService" (Raw:
                   "com.google.android.gms.measurement.AppMeasurementService")
                   A: android:enabled(0x0101000e)=(type 0x12)0xffffffff
                   A: android:exported(0x01010010)=(type 0x12)0x0
                 E: service (line=113)
                   A:
                   android:name(0x01010003)="com.google.android.gms.measurement.
                   AppMeasurementJobService" (Raw:
                   "com.google.android.gms.measurement.AppMeasurementJobService"
                   )
                   A:
                   android:permission(0x01010006)="android.permission.BIND_JOB_S
                   ERVICE" (Raw: "android.permission.BIND_JOB_SERVICE")
                   A: android:enabled(0x0101000e)=(type 0x12)0xffffffff
                   A: android:exported(0x01010010)=(type 0x12)0x0
                 E: provider (line=119)
                   A:
                   android:name(0x01010003)="com.google.firebase.provider.Fireba
                   seInitProvider" (Raw:
                   "com.google.firebase.provider.FirebaseInitProvider")
                   A: android:exported(0x01010010)=(type 0x12)0x0
                   A:
                   android:authorities(0x01010018)="com.techstar.sunwaybooster.f
                   irebaseinitprovider" (Raw:
                   "com.techstar.sunwaybooster.firebaseinitprovider")
                   A: android:initOrder(0x0101001a)=(type 0x10)0x64
                 E: meta-data (line=125)
                   A: android:name(0x01010003)="com.google.android.gms.version"
                   (Raw: "com.google.android.gms.version")
                   A: android:value(0x01010024)=@0x7f060000
[  +14 ms] Stopping app 'app.apk' on SM G935F.
[   +1 ms] executing: /Users/rafidkarim/Library/Android/sdk/platform-tools/adb
-s 9885e6494544364944 shell am force-stop com.techstar.sunwaybooster
[ +127 ms] executing: /Users/rafidkarim/Library/Android/sdk/platform-tools/adb
-s 9885e6494544364944 shell pm list packages com.techstar.sunwaybooster
[ +943 ms] package:com.techstar.sunwaybooster
[   +4 ms] executing: /Users/rafidkarim/Library/Android/sdk/platform-tools/adb
-s 9885e6494544364944 shell cat
/data/local/tmp/sky.com.techstar.sunwaybooster.sha1
[  +45 ms] 4423ab3ded33f0b36290722420e2cef86fb2fc07
[        ] Latest build already installed.
[        ] SM G935F startApp
[   +1 ms] executing: /Users/rafidkarim/Library/Android/sdk/platform-tools/adb
-s 9885e6494544364944 shell am start -a android.intent.action.RUN -f 0x20000000
--ez enable-background-compilation true --ez enable-dart-profiling true --ez
enable-checked-mode true --ez verify-entry-points true
com.techstar.sunwaybooster/com.techstar.sunwaybooster.MainActivity
[ +149 ms] Starting: Intent { act=android.intent.action.RUN flg=0x20000000
cmp=com.techstar.sunwaybooster/.MainActivity (has extras) }
[        ] Waiting for observatory port to be available...

这是flutter doctor


[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
[✓] iOS tools - develop for iOS devices
[✓] Android Studio (version 3.3)
[✓] VS Code (version 1.38.0)
[✓] Connected device (5 available)

和 AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.test.app">

    <!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement
         FlutterApplication and put your custom class here. -->
    <application
        android:name="io.flutter.app.FlutterApplication"
        android:label="Sunway Booster"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- This keeps the window background of the activity showing
                 until Flutter renders its first frame. It can be removed if
                 there is no splash screen (such as the default splash screen
                 defined in @style/LaunchTheme). -->
            <meta-data
                android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
                android:value="true" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>
</manifest>

我需要从 fit_kit 获取健康数据,对于 iOS,它可以正常工作,但在 Android 端,应用程序在启动时总是崩溃。我放不下--verbose

【问题讨论】:

    标签: android flutter


    【解决方案1】:

    您是否在 Android Studio 中添加了 App 文件夹 google-services 文件?如果您还没有添加它,您的 iOS 应用将在您的应用打开时自动关闭。

    如果您不知道如何找到这些文件。请按照以下步骤操作;

    1. 去火力基地console
    2. 请点击屏幕左侧的设置按钮
    3. 项目设置
    4. 您的应用 - 点击您的 iOS 应用
    5. 下载 google-services.json

    【讨论】:

    • 您可以更改崩溃详细信息的日志级别吗?如果您使用 Android Studio,请将此“仅显示选定的应用程序”更改为“无过滤器”,您可以看到崩溃行或有关崩溃的更多详细信息。但是如果你使用 VS Code 我不知道如何更改应用程序过滤器。
    • 好吧,让我试试。我正在使用 VS Code,尝试过 Android Studio,但它不起作用。运行按钮以某种方式被禁用,它要求我添加新配置。
    猜你喜欢
    • 2019-01-24
    • 1970-01-01
    • 2018-10-22
    • 2018-12-26
    • 2021-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多