【问题标题】:GCM unable to start service intentGCM 无法启动服务意图
【发布时间】:2018-12-14 11:23:26
【问题描述】:

从 android P 开始,我的应用无法注册 GCM ID。我的 PushManager 代码看起来像

try
        {
            GcmClient.CheckDevice(context);
            GcmClient.CheckManifest(context);
            String[] senderIds = GcmBroadcastReceiver.SENDER_IDS;
            foreach (String id in senderIds)
            {
                System.Diagnostics.Debug.WriteLine("sender id = " + id);
            }

            GcmClient.Register(context, senderIds);

            if (GcmClient.IsRegistered(context))
            {
                System.Diagnostics.Debug.WriteLine("push registration successfull: " +
                                                   GcmClient.GetRegistrationId(context));
            }
        }
        catch (Exception e)
        {
            System.Diagnostics.Debug.WriteLine("push registration failed: " + e.Message.ToString());
        }

我的清单:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="my.app" android:versionName="1.8.5" android:versionCode="97">
    <uses-sdk android:minSdkVersion="16" />
    <application android:label="My app" android:icon="@mipmap/icon" android:theme="@style/Theme.App" android:hardwareAccelerated="true" android:windowSoftInputMode="stateHidden|adjustResize" android:name="android.support.multidex.MultiDexApplication">
        <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:theme="@android:style/Theme.Translucent" />
    </application>
    <permission android:name="com.rotogrinders.rg_lineups.permission.C2D_MESSAGE" android:protectionLevel="signature" />
    <uses-permission android:name="com.rotogrinders.rg_lineups.permission.C2D_MESSAGE" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="com.android.vending.BILLING" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <permission android:name="android.permission.STATUS_BAR_SERVICE" android:protectionLevel="signature" />
<!-- For Google Play Services -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
    <action android:name="com.google.android.c2dm.intent.REGISTER" />
    <service android:name="com.google.android.gms.analytics.AnalyticsService" android:enabled="true" android:exported="false" />

每当我尝试注册或注销时,我都会收到此错误:

07-05 16:35:49.156 W/ActivityManager( 1167): Unable to start service Intent { act=com.google.android.c2dm.intent.UNREGISTER pkg=com.google.android.gsf (has extras) } U=0: not found
07-05 16:35:49.169 W/ActivityManager( 1167): Unable to start service Intent { act=com.google.android.c2dm.intent.REGISTER pkg=com.google.android.gsf (has extras) } U=0: not found

我发现运行旧操作系统的设备可以正常注册。到目前为止,我遇到的唯一问题是 android P 预览版。任何帮助,将不胜感激。

【问题讨论】:

  • 您为什么使用 GCM?它很快就会被取出,我建议你改用 FCM
  • 切换到 FCM 是我的待办事项。我在考虑忽略这个问题,并希望 FCM 能解决这个问题。
  • 前几天在 FCM 上工作就像在 Android P 上的魅力一样在这里查看如何做:stackoverflow.com/a/48089829/7462031

标签: android xamarin.android google-cloud-messaging


【解决方案1】:

您可能使用的是旧版本的 GCM。

您可以升级到 GCM 11 或更高版本,甚至更好,迁移到 FCM。 (GCM 现已弃用)

(GCM最新版本为15.0.1:com.google.android.gms:play-services-gcm:15.0.1)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-22
    相关资源
    最近更新 更多