How to setup Android Firebase Notification in Manifest?

coolamz picture coolamz · Sep 24, 2016 · Viewed 10.7k times · Source

I'm trying to setup Firebase notifications. I did changes in app level and root level build.gradle. But still, its giving me error in Manifest for MyFirebaseMessagingService. Error is Unresolved Class.

<?xml version="1.0" encoding="utf-8"?>

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

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">


        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <action android:name="com.google.firebase.MESSAGING_EVENT"/>
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".s" />
    <activity android:name=".im" />
    <activity android:name=".Main2Activity" />
    <activity android:name=".sactivity" />
    <service
        android:name=".MyFirebaseMessagingService">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT"/>
        </intent-filter>
    </service>
    <activity
        android:name=".ScrollingActivity"
        android:label="@string/title_activity_scrolling"
        android:theme="@style/AppTheme.NoActionBar"></activity>
</application>

Answer

looptheloop88 picture looptheloop88 · Sep 27, 2016

Looks like the Android Manifest file can't locate the MyFirebaseMessagingService class. I'd suggest you to put the fully qualified package name of the class. See example below:

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