1

我正在实施和添加 FirebaseCrash 的 InstantApp。

我按照所有步骤进行设置,当我使用可安装版本的构建配置运行应用程序时,它就像一个魅力,但是当我尝试运行 InstantApp FirebaseCrash 的构建配置时,应用程序崩溃了。

该行中的应用程序崩溃,我正在模拟崩溃只是为了检查它是否有效:

FirebaseCrash.logcat(Log.ERROR, "Firebase", "I am broken!!");

这是我为 InstantApp 运行它时的崩溃:

Process: uk.co.alpha.test.app, PID: 3516                                               
java.lang.RuntimeException: Unable to start activity 
ComponentInfo{[package.class]}: java.lang.IllegalStateException: 
Default FirebaseApp is not initialized in this process [package] Make 
sure to call FirebaseApp.initializeApp(Context) first.

我尝试在它崩溃的类的 onCreate 中添加 FirebaseApp.initializeApp(Context),我还尝试将它添加到从 Application 扩展的类中,但出现相同的崩溃。

我检查了 stackoverflow 和官方 Firebase 文档,但没有找到任何特定于 InstantApps 的内容

它适用于可安装版本,但我添加了我的 gradle 文件以防万一它可以帮助解决它:

./build.gradle

buildscript {
    repositories {
        jcenter()
        mavenCentral()
        maven { url 'https://maven.google.com'}
        //Dexcount Gradle Plugin
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-alpha5'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:3.0.0'
        //Dexcount Gradle Plugin
        classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.7.0-SNAPSHOT'
    }
}

allprojects {
    repositories {
        jcenter()
        mavenCentral()
        maven { url 'https://maven.google.com' }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

ext {
    buildTools = '25.0.2'
    compileSdk = 25
    minSdk = 23
    versionCode = 11
    versionName = '4.0'
    supportLib = '25.3.1'
    playServices = "11.0.0"
}

功能/build.gradle

buildscript {
    repositories {
        jcenter()
    }
}
apply plugin: 'com.android.feature'

repositories {
    jcenter()
    mavenCentral()
}

android {
    compileSdkVersion rootProject.compileSdk
    buildToolsVersion rootProject.buildTools

    baseFeature true
    defaultConfig {
        minSdkVersion rootProject.minSdk
        targetSdkVersion rootProject.compileSdk
        versionCode rootProject.versionCode
        versionName rootProject.versionName
    }

    compileOptions {
    targetCompatibility JavaVersion.VERSION_1_8
    sourceCompatibility JavaVersion.VERSION_1_8
}

signingConfigs {
    release {
        storeFile file("instantApp_keystore")
        storePassword "..."
        keyAlias "..."
        keyPassword "..."
    }
}

buildTypes {
    debug {
        buildConfigField "String", "PARSE_BACKUP", "\"" + PARSE_BACKUP + "\""
        buildConfigField "String", "PARSE", "\"" + PARSE_LIVE + "\""
        buildConfigField "String", "PARSE_APP_ID", "\"" + parseAppId_LIVE + "\""
        buildConfigField "String", "PARSE_CLIENT_KEY", "\"" + parseClientKey_LIVE + "\""
    }
    release {
        signingConfig signingConfigs.release
        buildConfigField "String", "PARSE_BACKUP", "\"" + PARSE_BACKUP + "\""
        buildConfigField "String", "PARSE", "\"" + PARSE_LIVE + "\""
        buildConfigField "String", "PARSE_APP_ID", "\"" + parseAppId_LIVE + "\""
        buildConfigField "String", "PARSE_CLIENT_KEY", "\"" + parseClientKey_LIVE + "\""
    }
}

packagingOptions {
    exclude 'META-INF/rxjava.properties'
}
}

dependencies {
    compile "com.android.support:appcompat-v7:${rootProject.supportLib}"
    compile "com.android.support:design:${rootProject.supportLib}"
    compile "com.google.android.gms:play-services-analytics:${rootProject.playServices}"

    compile 'com.parse:parse-android:1.14.1'
    compile 'com.squareup:otto:1.3.8'
    compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
    compile ('cn.trinea.android.view.autoscrollviewpager:android-auto-scroll-view-pager:1.1.2'){
        exclude module: 'support-v4'
    }
    compile 'me.relex:circleindicator:1.2.2@aar'
    compile 'com.squareup.picasso:picasso:2.5.2'

    compile "com.google.firebase:firebase-crash:${rootProject.playServices}"
}
apply plugin: 'com.google.gms.google-services'

提前致谢!!!!;)

4

1 回答 1

2

不幸的是,Firebase 崩溃报告不适用于即时应用,也没有计划专门更新它以与即时应用一起使用。这是因为 Fabric 现在是 Firebase 团队的一员,Fabric Crashlytics 是未来工作的重点。Firebase文档也提到了这一点。

Crashlytics 已经可以与 Instant Apps 一起使用,有关设置的信息,请参阅这篇文章:

如何将 Crashlytics 与 Android Instant Apps 集成?

于 2017-07-08T00:14:03.507 回答