在Android上实施FCM(Firebase Cloud Messaging)后,应用在启动时崩溃了吗?

时间:2018-06-29 16:14:10

标签: android firebase firebase-realtime-database firebase-authentication firebase-cloud-messaging

我需要在android应用程序中使用通知服务,并且想要实现FCM(Firebase云消息传递),我编译了所需的库,并在AndroidManifest.xml中添加了该服务并创建了所需的类。设置完所有这些后,我的应用程序启动后便崩溃了。

应用程序级别gradle:

apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
    applicationId "com.example.ayushsrivastava.arc"
    minSdkVersion 19
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner 
   "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 
    'proguard-rules.pro'
     }
    }
    }

    dependencies {
    compile 'com.firebase:firebase-client-android:2.5.0'
    compile 'com.google.firebase:firebase-core:11.8.0'
    compile 'com.google.firebase:firebase-database:11.8.0'
    compile 'com.google.firebase:firebase-auth:11.8.0'
    compile 'com.google.firebase:firebase-crash:11.8.0'
    compile 'com.google.firebase:firebase-storage:11.8.0'
    compile 'com.google.firebase:firebase-messaging:11.8.0'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support:cardview-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:design:26.1.0'
     implementation 'com.squareup.picasso:picasso:2.71828'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:0.5'
    androidTestImplementation 'com.android.support.test.espresso:espresso-
    core:2.2.2'

    }
    apply plugin: 'com.google.gms.google-services'

角色级别gradle:

buildscript {

repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.0.0'
    classpath 'com.google.gms:google-services:4.0.1'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

 allprojects {
 repositories {
    google()
    jcenter()
 }
 }

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

Logcat:

06-29 21:12:37.456 29892-29892/com.example.ayushsrivastava.arc 
  E/UncaughtException: java.lang.NoSuchMethodError: No virtual method 
  zzbqp()Ljava/lang/String; in class Lcom/google/firebase/FirebaseApp; or its 
  super classes (declaration of 'com.google.firebase.FirebaseApp' appears in 
  /data/app/com.example.ayushsrivastava.arc-2/base.apk)



    at com.google.firebase.auth.FirebaseAuth.zzb(Unknown Source)

    at com.google.firebase.auth.FirebaseAuth.getInstance(Unknown Source)

    at com.example.ayushsrivastava.arc.MainActivityLogin.onCreate(MainActivityLogin.java:85)

MainActivityLogin.java:85:

     firebaseAuth = FirebaseAuth.getInstance();

1 个答案:

答案 0 :(得分:-1)

使用firebase助手安装所有依赖项。 选择选项“云消息传递”

enter image description here

enter image description here