我正在使用React Native来构建使用Firebase Messaging,Invites等的应用程序。在我将Firebase邀请/链接添加到该应用程序之前,该应用程序运行良好。现在;即使该应用可以构建和运行,但在收到推送通知时也会崩溃。日志显示:
FATAL EXCEPTION: Firebase-RNFirebaseMessagingService
09-06 15:59:43.724 19077 19566 E AndroidRuntime: Process: com.myapp, PID: 19077
09-06 15:59:43.724 19077 19566 E AndroidRuntime: java.lang.NoSuchFieldError: No static field zzadc of type [Ljava/lang/String; in class Lcom/google/android/gms/measurement/AppMeasurement$UserProperty; or its superclasses (declaration of 'com.google.android.gms.measurement.AppMeasurement$UserProperty' appears in /data/app/com.myapp-1/base.apk)
09-06 15:59:43.724 19077 19566 E AndroidRuntime: at com.google.firebase.analytics.connector.internal.zzb.<clinit>(Unknown Source)
09-06 15:59:43.724 19077 19566 E AndroidRuntime: at com.google.firebase.analytics.connector.AnalyticsConnectorImpl.logEvent(Unknown Source)
09-06 15:59:43.724 19077 19566 E AndroidRuntime: at com.google.firebase.messaging.zzb.zzc(Unknown Source)
09-06 15:59:43.724 19077 19566 E AndroidRuntime: at com.google.firebase.messaging.zzb.zze(Unknown Source)
09-06 15:59:43.724 19077 19566 E AndroidRuntime: at com.google.firebase.messaging.FirebaseMessagingService.zzd(Unknown Source)
09-06 15:59:43.724 19077 19566 E AndroidRuntime: at com.google.firebase.iid.zzc.run(Unknown Source)
09-06 15:59:43.724 19077 19566 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
09-06 15:59:43.724 19077 19566 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
09-06 15:59:43.724 19077 19566 E AndroidRuntime: at com.google.android.gms.common.util.concurrent.zza.run(Unknown Source)
09-06 15:59:43.724 19077 19566 E AndroidRuntime: at java.lang.Thread.run(Thread.java:818)
我认为这是因为方法数量超过了65k的限制,并使用了multiDex和proguard,但结果似乎是相同的。由于堆栈跟踪显示了分析;我也尝试过包括Firebase Analytics,但是也没有用。以下是我的build.gradle:
apply plugin: "com.android.application"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
def enableProguardInReleaseBuilds = true
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.myapp"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
signingConfigs {
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
implementation project(':react-native-firebase')
//For Firebase
implementation "com.google.android.gms:play-services-base:15.0.1"
implementation "com.google.firebase:firebase-core:16.0.0"
implementation "com.google.firebase:firebase-auth:16.0.2"
implementation "com.google.firebase:firebase-messaging:17.1.0"
implementation "com.google.firebase:firebase-functions:16.0.1"
implementation "com.google.firebase:firebase-invites:16.0.1"
implementation project(':realm')
implementation project(':react-native-pdf')
implementation project(':react-native-fetch-blob')
implementation (project(':react-native-camera')) {
exclude group: "com.android.support"
}
implementation project(':react-native-image-picker')
implementation project(':react-native-localization')
implementation project(':react-native-fbsdk')
implementation project(':react-native-linear-gradient')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:23.0.1"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation 'com.android.support:multidex:1.0.3'
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
在这一点上,我现在还不确定如何处理。有人有这个问题或想法吗?
答案 0 :(得分:0)
由于Nizam的评论,我设法通过增加Firebase核心,身份验证和消息传递的版本来解决此问题。固定版本如下所示(gradle文件的其余部分相同):
implementation "com.google.android.gms:play-services-base:15.0.1"
implementation "com.google.firebase:firebase-core:16.0.1"
implementation "com.google.firebase:firebase-auth:16.0.3"
implementation "com.google.firebase:firebase-messaging:17.3.0"
implementation "com.google.firebase:firebase-functions:16.0.1"
implementation "com.google.firebase:firebase-invites:16.0.1"
答案 1 :(得分:0)
添加为答案: 在我的一个正在运行的项目中,
// Firebase dependencies
implementation 'com.google.firebase:firebase-invites:16.0.1'
implementation "com.google.android.gms:play-services-base:15.0.1"
implementation "com.google.android.gms:play-services-auth:16.0.0"
implementation "com.google.firebase:firebase-core:16.0.1"
implementation "com.google.firebase:firebase-auth:16.0.3"
implementation "com.google.firebase:firebase-firestore:17.1.0"
implementation "com.google.firebase:firebase-messaging:17.3.0"