FirebaseCrash 不适用于 InstantApps
Posted
技术标签:
【中文标题】FirebaseCrash 不适用于 InstantApps【英文标题】:FirebaseCrash is not working for InstantApps 【发布时间】:2017-07-06 11:04:11 【问题描述】:我正在实施我添加 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 扩展的类中,但出现相同的崩溃。
我查看了 *** 和 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'
提前谢谢!!!! ;)
【问题讨论】:
这里是与免安装应用兼容的库列表:developer.android.com/topic/instant-apps/… 【参考方案1】:很遗憾,Firebase 崩溃报告不适用于免安装应用,也没有计划专门更新它以使用免安装应用。这是因为 Fabric 现在是 Firebase 团队的一员,Fabric Crashlytics 是未来工作的重点。 Firebase docs 也提到了这一点。
Crashlytics 已经可以与 Instant Apps 一起使用,有关设置的信息,请参阅这篇文章:
How do I integrate Crashlytics with Android Instant Apps?
【讨论】:
以上是关于FirebaseCrash 不适用于 InstantApps的主要内容,如果未能解决你的问题,请参考以下文章