Gert-Jan Schaap
Gert-Jan Schaap

Reputation: 63

Firebase Messaging crashes my app?

I have followed these instructions so that I can use Firebase Messaging in my app: https://www.youtube.com/watch?v=rq-Axj79iNo . Unfortanetely, my app crashes immediately when I press "SEND" on my computer at the Firebase Console. I get this Error:

04-24 18:43:02.847 21312-21351/com.thisIsMyApplicationId E/AndroidRuntime: FATAL EXCEPTION: pool-1-thread-1
                                                                         Process: com.thisIsMyApplicationId, PID: 21312
                                                                         java.lang.AbstractMethodError: abstract method "void com.google.firebase.iid.zzb.handleIntent(android.content.Intent)"
                                                                             at com.google.firebase.iid.zzb$1.run(Unknown Source)
                                                                             at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                                                                             at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                                                                             at java.lang.Thread.run(Thread.java:818)

Maybe this could be the cause of my problem: My app requires no permission at all. Does it need permission if I want to use Firebase Messaging? Or is it something else. How can I solve this?

Some helpful files:

build.gradle at App Directory:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "25.0.0"
    defaultConfig {
        applicationId "com.myApplicationId"
        minSdkVersion 15
        targetSdkVersion 24
        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 fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:24.2.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile 'com.google.firebase:firebase-core:10.2.1'
    compile 'com.google.firebase:firebase-messaging:9.0.0'
}

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

build.gradle at Gradle Directory:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

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

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

allprojects {
    repositories {
        jcenter()
    }
}

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

For the rest, I added google-services.json to my App Directory.

In addition to these files, I did not change any other file.

How can I solve the problem described above?

Upvotes: 0

Views: 2284

Answers (2)

Gert-Jan Schaap
Gert-Jan Schaap

Reputation: 63

The problem is, your app has no permission to use the Internet, if not, you can't receive any notification from Firebase, because Firebase Messages come from the Internet!

Add these lines to your AndroidManifest.xml as a direct child of manifest:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Hope this will help!

Upvotes: 1

HerberthObregon
HerberthObregon

Reputation: 2151

You use de core 10.2.1 and messaging:9.0.0

you should use :

compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-messaging:10.2.1'

I hope it helped you

Upvotes: 0

Related Questions