无法解析 Intent Service Android

6
我尝试配置推送通知时遇到了以下错误:
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.

我在Gradle中有不同的版本:

我的代码包名称是:com.ebr.apps.ebr 我的产品版本包名称是:com.ebr.apps.ebr.development

我已将google-services.json放置在app/src/development目录下

清单文件:

    <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>

我看过很多例子,但仍然出现这个错误。
2个回答

7

我找到了解决方案,问题在于Instabug的GCMListener与我的GCMListener发生了冲突。我设置了我的GCM监听器的优先级,然后它就开始工作了。

<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>

你应该将这个标记为已接受的答案。 :) - AL.
文档中说:“该值必须大于-1000且小于1000。”那么10000是有意的吗?https://developer.android.com/reference/android/content/IntentFilter.html#SYSTEM_HIGH_PRIORITY - shkschneider

2
如果你是从搜索引擎来的:你可能也遇到了这个 bug,它也影响了当前版本 com.google.android.gms:play-services-gcm:9.8.0。

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

目前还无法重现这个错误,也没有完全理解这种情况是如何发生的,但你可能会对跟进这个线程感兴趣。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接