2

I finally start to experiment with Firebase Cloud Messaging Service in Android Studio. I try this tutorial and I have exactly the same classes like in this tutorial: enter link description here

  1. My first Question is, why did the "Android Monitor" in Android Studio, show me the device token only one time? Everytime I start a new Project in Firebase and connect it with my AppProjekt and run it, the Token just showed me the first time when I run the project without troubles. If I run it again, I don't see anything of this Token, nothing!

  2. Second Question is, why I don't get the Push Notification from Firebase?

Here is my Android Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.felixkoepping.pushtest2">

<uses-permission android:name="android.permission.INTERNET"/>
<application
    android:name="android.support.multidex.MultiDexApplication"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <service
        android:name=".MyFirebaseMessagingService">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT"/>
        </intent-filter>
    </service>

    <service
        android:name=".MyFirebaseInstanceIDService">
        <intent-filter>
            <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
        </intent-filter>
    </service>
</application>

Here is the gradle File in app Section:

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion '25.0.3'
defaultConfig {
    multiDexEnabled true
    applicationId "com.example.felixkoepping.pushtest2"
    minSdkVersion 19
    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'
    }
}
}

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 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'

compile 'com.google.firebase:firebase-messaging:9.2.0'
compile 'com.google.firebase:firebase-core:9.2.0'
compile 'com.android.support:multidex:1.0.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

Here is the gradle File of the project Section:

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

The only "red Message" in Android Monitor is:

E/FA: Failed to send event to AppMeasurementService: 
android.os.DeadObjectException: 
com.google.android.gms.measurement.internal.zzm$zza$zza.zza(Unknown Source)

If I send a notification from the Console in Firebase to exactly this Device with the Token, nothing will be shown in my Emulator...

I hope some of you guys can help me with this Problem. I tried so much, but nothing works...

Thanks Guys :-)

KENdi
  • 7,576
  • 2
  • 16
  • 31
Felix
  • 21
  • 1
  • Hi Felix. "*I tried so much, but nothing works*" -- what exactly have you tried? I see that you followed the tutorial, but I'm looking for the stuff you already did to debug your issue. It'd be great if you post them as well so we can narrow down the places where to look. :) – AL. Jul 15 '17 at 06:14

1 Answers1

0

thanks for writing in. I'll be helping today to get your problem resolved.

  • The notification sent from the console will show up only when the app is closed or in it's background state.

  • To make the app show notifications in the foreground state, refer to this link Firebase notifications in the foreground

If you're still unaware of what happens, ping me through the comment facility, thanks!

Praveen Thirumurugan
  • 977
  • 1
  • 12
  • 27