Firebase可调用函数出错 [英] Error with Firebase callable functions
本文介绍了Firebase可调用函数出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在我的Android应用中设置可调用的Firebase云功能.为此,根据本教程,我需要使用以下代码来初始化SDK:
I am trying to set up callable Firebase cloud functions in my Android app. To do that, per this tutorial, I need to use the following code to initialize the SDK:
FirebaseFunctions f = FirebaseFunctions.getInstance();
但是,当我这样做时,应用程序因以下错误而崩溃:
However, when I do this, the app crashes with this error:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: mhealth.mvax.qa, PID: 5390
java.lang.NullPointerException
at com.google.firebase.functions.internal.Preconditions.checkNotNull(Preconditions.java:876)
at com.google.firebase.functions.FirebaseFunctions.<init>(FirebaseFunctions.java:77)
at com.google.firebase.functions.FirebaseFunctions.getInstance(FirebaseFunctions.java:141)
at com.google.firebase.functions.FirebaseFunctions.getInstance(FirebaseFunctions.java:159)
at mhealth.mvax.auth.modals.ApproveUserModal.approveRequest(ApproveUserModal.java:143)
at mhealth.mvax.auth.modals.ApproveUserModal.lambda$null$0$ApproveUserModal(ApproveUserModal.java:92)
似乎Firebase代码中使用的projectId字段为null,这会导致错误.我不确定该如何解决.
It seems that the projectId field used in the Firebase code is null and this causes the error. I'm not sure how to get around this.
这是我的 build.gradle
:
apply plugin: 'com.android.application'
android {
signingConfigs {
development {
keyAlias 'Development Key Store'
keyPassword 'REDACTED'
storeFile file('../keystores/development_key_store')
storePassword 'REDACTED'
}
}
compileSdkVersion 26
defaultConfig {
applicationId "mhealth.mvax"
minSdkVersion 24
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
flavorDimensions "default"
productFlavors {
dev {
applicationId 'mhealth.mvax.dev'
minSdkVersion 24
targetSdkVersion 24
signingConfig signingConfigs.development
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}
qa {
applicationId 'mhealth.mvax.qa'
minSdkVersion 24
targetSdkVersion 24
signingConfig signingConfigs.development
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}
prod {
applicationId 'mhealth.mvax.prod'
minSdkVersion 24
targetSdkVersion 24
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}
}
buildTypes {
debug {
debuggable true
minifyEnabled false
}
release {
debuggable false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
// ultimately we may want checkReleaseBuilds and abortOnError to be true
checkReleaseBuilds false
abortOnError false
}
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] } }
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:support-v13:26.1.0' // must use v13 for ViewPager
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.jjoe64:graphview:4.2.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-database:12.0.1'
implementation 'com.google.firebase:firebase-auth:12.0.1'
implementation 'com.google.android.gms:play-services-auth:12.0.1'
implementation 'com.google.firebase:firebase-invites:12.0.1'
implementation 'com.google.firebase:firebase-functions:12.0.1'
implementation 'com.algolia:algoliasearch-android:3.10.1'
implementation 'joda-time:joda-time:2.9.9'
androidTestImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.12'
implementation files('libs/itext5-itextpdf-5.5.12.jar')
testImplementation 'org.hamcrest:hamcrest-library:1.3'
implementation files('libs/javax.mail.jar')
}
apply plugin: 'com.google.gms.google-services'
推荐答案
我通过更改解决了该问题
I solved this by changing
'com.google.gms:google-services:3.0.0'
到
'com.google.gms:google-services:3.1.0'
在我的项目级别 build.gradle
.
这篇关于Firebase可调用函数出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文