从Google我们网站下载插件并成功运行解析器后,我已经实现了Firebase Analytics和Firebase Messaging。 问题是在构建后,当App第一次运行时它崩溃并显示以下错误,但是从第二次开始,该应用程序不会崩溃 这是日志
FATAL EXCEPTION: main
Process: com.lemontart.flying.robot.car.transformation, PID: 27861
java.lang.RuntimeException: Unable to instantiate service com.google.firebase.messaging.cpp.ListenerService: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.messaging.cpp.ListenerService" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.lemontart.flying.robot.car.transformation-EVwlnR7Mxf4TO-7_HvK44w==/base.apk"],nativeLibraryDirectories=[/data/app/com.lemontart.flying.robot.car.transformation-EVwlnR7Mxf4TO-7_HvK44w==/lib/arm, /data/app/com.lemontart.flying.robot.car.transformation-EVwlnR7Mxf4TO-7_HvK44w==/base.apk!/lib/armeabi-v7a, /system/lib]]
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3654)
at android.app.ActivityThread.access$1500(ActivityThread.java:207)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1764)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6863)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.messaging.cpp.ListenerService" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.lemontart.flying.robot.car.transformation-EVwlnR7Mxf4TO-7_HvK44w==/base.apk"],nativeLibraryDirectories=[/data/app/com.lemontart.flying.robot.car.transformation-EVwlnR7Mxf4TO-7_HvK44w==/lib/arm, /data/app/com.lemontart.flying.robot.car.transformation-EVwlnR7Mxf4TO-7_HvK44w==/base.apk!/lib/armeabi-v7a, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:169)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.AppComponentFactory.instantiateService(AppComponentFactory.java:103)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3649)
at android.app.ActivityThread.access$1500(ActivityThread.java:207)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1764)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6863)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Suppressed: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/messaging/FirebaseMessagingService;
at java.lang.VMClassLoader.findLoadedClass(Native Method)
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:738)
at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
... 11 more
Caused by: java.lang.ClassNotFoundException: com.google.firebase.messaging.FirebaseMessagingService
at java.lang.VMClassLoader.findLoadedClass(Native Method)
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:738)
at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 14 more
Caused by: java.lang.IllegalAccessError: Class com.google.firebase.iid.zzb extended by class com.google.firebase.messaging.FirebaseMessagingService is inaccessible (declaration of 'com.google.firebase.messaging.FirebaseMessagingService' appears in base.apk)
... 14 more
2019-05-17 12:55:18.960 27861-27861/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.lemontart.flying.robot.car.transformation, PID: 27861
java.lang.Error: FATAL EXCEPTION [main]
Unity version : 2018.3.14f1
Device model : OnePlus ONEPLUS A5000
Device fingerprint: OnePlus/OnePlus5/OnePlus5:9/PKQ1.180716.001/1904191514:user/release-keys
Caused by: java.lang.RuntimeException: Unable to instantiate service com.google.firebase.messaging.cpp.ListenerService: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.messaging.cpp.ListenerService" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.lemontart.flying.robot.car.transformation-EVwlnR7Mxf4TO-7_HvK44w==/base.apk"],nativeLibraryDirectories=[/data/app/com.lemontart.flying.robot.car.transformation-EVwlnR7Mxf4TO-7_HvK44w==/lib/arm, /data/app/com.lemontart.flying.robot.car.transformation-EVwlnR7Mxf4TO-7_HvK44w==/base.apk!/lib/armeabi-v7a, /system/lib]]
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3654)
at android.app.ActivityThread.access$1500(ActivityThread.java:207)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1764)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6863)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.messaging.cpp.ListenerService" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.lemontart.flying.robot.car.transformation-EVwlnR7Mxf4TO-7_HvK44w==/base.apk"],nativeLibraryDirectories=[/data/app/com.lemontart.flying.robot.car.transformation-EVwlnR7Mxf4TO-7_HvK44w==/lib/arm, /data/app/com.lemontart.flying.robot.car.transformation-EVwlnR7Mxf4TO-7_HvK44w==/base.apk!/lib/armeabi-v7a, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:169)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.AppComponentFactory.instantiateService(AppComponentFactory.java:103)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3649)
at android.app.ActivityThread.access$1500(ActivityThread.java:207)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1764)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6863)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Suppressed: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/messaging/FirebaseMessagingService;
at java.lang.VMClassLoader.findLoadedClass(Native Method)
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:738)
at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
我看到所有的jar和aar都将其提交给该项目,但我仍然无法解决问题。 这是我的gradle文件
// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
**BUILD_SCRIPT_DEPS**}
}
allprojects {
repositories {
google()
jcenter()
flatDir {
dirs 'libs'
}
}
}
// Android Resolver Repos Start
allprojects {
repositories {
maven {
url "https://maven.google.com"
}
maven {
url "https://maven.google.com/" // Assets/Consoliads/Editor/ConsoliAdsDependencies.xml:7
}
maven {
url "file:////Volumes/JawadData/Unity%20Projects/Consoli%204.6.2%20Unity%202018/Assets/Firebase/m2repository" // Assets/Firebase/Editor/AnalyticsDependencies.xml:22, Assets/Firebase/Editor/AppDependencies.xml:22
}
mavenLocal()
jcenter()
mavenCentral()
}
}
// Android Resolver Repos End
apply plugin: 'com.android.application'
**APPLY_PLUGINS**
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:multidex:1.0.1'
**DEPS**}
android {
compileSdkVersion **APIVERSION**
buildToolsVersion '**BUILDTOOLS**'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
multiDexEnabled true
minSdkVersion **MINSDKVERSION**
targetSdkVersion **TARGETSDKVERSION**
applicationId '**APPLICATIONID**'
ndk {
abiFilters **ABIFILTERS**
}
versionCode **VERSIONCODE**
versionName '**VERSIONNAME**'
}
lintOptions {
abortOnError false
}
aaptOptions {
noCompress = ['.unity3d', '.ress', '.resource', '.obb'**STREAMING_ASSETS**]
}**SIGN**
buildTypes {
debug {
minifyEnabled **MINIFY_DEBUG**
useProguard **PROGUARD_DEBUG**
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD**
jniDebuggable true
}
release {
minifyEnabled **MINIFY_RELEASE**
useProguard **PROGUARD_RELEASE**
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD****SIGNCONFIG**
}
}**PACKAGING_OPTIONS****SPLITS**
**BUILT_APK_LOCATION**
bundle {
language {
enableSplit = false
}
density {
enableSplit = false
}
abi {
enableSplit = true
}
}
}**SPLITS_VERSION_CODE****REPOSITORIES****SOURCE_BUILD_SETUP**
我需要解决此问题,请帮助,我们将不胜感激。 谢谢
答案 0 :(得分:1)
尝试将此行添加到gradle:
implementation 'com.google.firebase:firebase-messaging:+'
我认为它应该到文档末尾,如果不能在其他类似地方尝试的话:
dependencies {
implementation 'com.google.firebase:firebase-messaging:+'
implementation fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:multidex:1.0.1'
**DEPS**}
或者在这里:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
implementation 'com.google.firebase:firebase-messaging:+'
**BUILD_SCRIPT_DEPS**}
}
答案 1 :(得分:0)
几天前,我遇到了同样的问题,并且通过将所有Firebase库更新为最新版本来解决了该问题。似乎它们之间的依赖关系可能是版本冲突。 您可以找到Firebase库here
的最新版本列表