Jit Dasgupta
Jit Dasgupta

Reputation: 57

Firebase API initialization failure.java.lang.reflect.InvocationTargetException

I have integrated the FCM Database in my Android project. I used it for chat application. Now I need to implement the cloud message(Push notification) using FireBase. After I implement the FCM, I got an error-

Firebase API initialization failure. java.lang.reflect.InvocationTargetException

I am sending the gradle script please have a look.

Module :app

apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
    applicationId "com.example.swatin.groupchatapplication"
    minSdkVersion 16
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
             }
           }
 }
 repositories {
 mavenCentral()
  maven { url 'https://maven.google.com' }
 }

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile project(':libbambuser-0.9.12')
compile 'com.basgeekball:awesome-validation:1.3'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.1.0'
compile 'com.razorpay:checkout:1.4.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.firebaseui:firebase-ui:2.0.1'
compile 'com.squareup.okhttp:okhttp:2.0.0'
compile 'com.squareup.okhttp3:okhttp:3.7.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.github.bumptech.glide:glide:4.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.volley:volley:1.0.0'
compile 'com.android.volley:volley:1.1.0-rc1'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.paypal.sdk:paypal-android-sdk:2.14.2'

testCompile 'junit:junit:4.12'
annotationProcessor 'com.github.bumptech.glide:compiler:4.3.1'
} 
apply plugin: 'com.google.gms.google-services'

build.gradle (Project: ProjectName)

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.3.3'

    // 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'
}
}

allprojects {
repositories {
    jcenter()

}
}

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

Upvotes: 0

Views: 1809

Answers (1)

Alex Mamo
Alex Mamo

Reputation: 138824

To solve this, you need to add the following line of code:

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

As the last line in your build.gradle (Project: ProjectName) file.

And if you are using also authentication, please also this line of code:

compile 'com.google.android.gms:play-services-auth:10.0.1'

I also strongly recommend you to use the latest versions for your Firebase dependencies. The latest version is now: 11.8.0.

The last version for Google Play Services is:

classpath 'com.google.gms:google-services:3.2.0'

Upvotes: 3

Related Questions