Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to resolve Intent Service Android

I am getting following error when trying to configure Push Notification:

06-07 01:05:59.735 18708-18708/com.ebr.apps.ebr.development E/FirebaseInstanceId: Failed to resolve target intent service, skipping classname enforcement
06-07 01:05:59.735 18708-18708/com.ebr.apps.ebr.development E/FirebaseInstanceId: Error while delivering the message: ServiceIntent not found.

I have different flavors in gradle:

My code package name is : com.ebr.apps.ebr My product flavor package is: com.ebr.apps.ebr.development

I have placed google-services.json in app/src/development

Manifest:

    <permission
        android:name="${applicationId}.permission.C2D_MESSAGE"
        android:protectionLevel="signature"/>

    <uses-permission android:name="${applicationId}.permission.C2D_MESSAGE"/>

         <receiver
            android:name="com.google.android.gms.gcm.GcmReceiver"
            android:exported="true"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
                <category android:name="${applicationId}" />
            </intent-filter>
        </receiver>

        <service
            android:name=".GCM.PushNotificationService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
            </intent-filter>
        </service>

I have looked at many example but still getting this error.

like image 559
Nauman Afzaal Avatar asked Jun 06 '16 20:06

Nauman Afzaal


People also ask

What is an intentservice in Android?

What is IntentService in Android? IntentService in Android is a base class for Services to handle asynchronous requests that are expressed in the form of Intents when there is a demand to do so. The requests are sent by the clients through Context.startService (Intent) calls to start the service.

What happens if I unbind an intentservice from an app?

If the apps unbind the Service, it will be destroyed. The Service may be activated from any thread, but the IntentService can only be triggered from the main thread, which means that the Intent is received on the Main thread first, and then the Worker thread is run.

How do I start a service from an intent?

To start a Service, use the onStartService () function, but to start an IntentService, use Intent, i.e. start the IntentService by calling Context.startService (Intent). Because Service operates on the Main thread, there is a risk that your Main thread will be stopped if you utilise it.

Why we not add the self-stop method in intent services?

But you need to notice here that we not adding the self-stop method because this intent service is able to handle itself and it’s able to stop itself when all the works in the thread are done.


2 Answers

I found the solution, the problem was that Instabug GCMListener was conflicting with my GCMListener. I set the priority of my gcm listener and it started working.

<service
    android:name=".GCM.PushNotificationService"
    android:exported="false">
    <intent-filter android:priority="10000">
        <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
    </intent-filter>
</service>
like image 186
Nauman Afzaal Avatar answered Oct 19 '22 22:10

Nauman Afzaal


If your coming from a search engine: you might have as well run into this bug, which affects also the current version com.google.android.gms:play-services-gcm:9.8.0

https://github.com/firebase/quickstart-android/issues/72

It was not yet possible to reproduce the bug and it is not fully understood how the situation can happen but you might be interested in following the thread.

like image 2
Simon Warta Avatar answered Oct 19 '22 20:10

Simon Warta