亚马逊SNS Unity - 找不到GCMBroadcastReceiver

时间:2017-03-01 19:17:01

标签: java android unity3d aws-sdk amazon-sns

我已经阅读了关于亚马逊的SNS自述文件,它是git repo。

注册工作正常,移动设备会创建端点。使用arn端点发布消息,电话显示应用程序崩溃消息,其中包含以下堆栈跟踪:

03-01 19:53:34.781 17484 17484 E AndroidRuntime:java.lang.RuntimeException: Unable to instantiate receiver com.company.appname.GCMBroadcastReceiver: java.lang.ClassNotFoundException: Didn't find class "com.company.animamobile.GCMBroadcastReceiver" on path: DexPathList[[zip file "/data/app/com.company.appname-2/base.apk"],nativeLibraryDirectories=[/data/app/com.company.appname-2/lib/arm, /data/app/com.company.appname-2/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]

Assets / Plugins / Android包含所有相关的.jar文件,如果它包含使用jar tf cmd的类,我检查了amazon jar文件。它做了什么。

我的AndroidManifest.xml如下所示:

<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.company.appname"
      android:installLocation="preferExternal"
    android:versionCode="1"
    android:versionName="1.0">

  <supports-screens
      android:smallScreens="true"
      android:normalScreens="true"
      android:largeScreens="true"
      android:xlargeScreens="true"
      android:anyDensity="true"/>

  <uses-sdk android:minSdkVersion="15" />


  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.GET_ACCOUNTS" />
  <uses-permission android:name="android.permission.WAKE_LOCK" />
  <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

  <permission android:name="com.amazonaws.unity.permission.C2D_MESSAGE"
      android:protectionLevel="signature" />
  <uses-permission android:name="com.amazonaws.unity.permission.C2D_MESSAGE" />


  <application
      android:theme="@android:style/Theme.NoTitleBar"
      android:icon="@drawable/app_icon"
      android:label="@string/app_name"
      android:debuggable="true">

    <activity android:name="com.unity3d.player.UnityPlayerActivity"
              android:label="@string/app_name">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
        <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
      </intent-filter>
      <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
      <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
    </activity>

    <receiver
        android:name="com.company.appname.GCMBroadcastReceiver"
        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="com.company.appname" />
      </intent-filter>
    </receiver>

    <service android:name="com.company.appname.GCMIntentService" />
  </application>
</manifest>

[编辑]在发布之前,我决定进一步检查SO。找到一条建议添加google GCM.jar的帖子。我在AndroidManifest中做过和引用过的。应用程序现在没有崩溃所以我看了一下LogCat并获得了以下内容:

03-01 20:09:31.911  3582  3637 V BroadcastQueue: [background] Process cur broadcast BroadcastRecord{be5a3b5 u0 com.google.android.c2dm.intent.RECEIVE qIdx=4}, state= (APP_RECEIVE) DELIVERED for app ProcessRecord{d9ba83e 20867:com.company.appname/u0a253}
03-01 20:09:31.921 20867 20867 V GCMBroadcastReceiver: onReceive: com.google.android.c2dm.intent.RECEIVE
03-01 20:09:31.921 20867 20867 V GCMBroadcastReceiver: GCM IntentService class: com.company.appname.GCMIntentService
03-01 20:09:31.921 20867 20867 V GCMBaseIntentService: Acquiring wakelock
03-01 20:09:31.921  3582  5879 W ActivityManager: Unable to start service Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10 pkg=com.company.appname cmp=com.company.appname/com.activate.gcm.GCMIntentService bqHint=4 (has extras) } U=0: not found

1 个答案:

答案 0 :(得分:0)

原来我的android-support-v4.jar没有包含WakefullBroadcastReceiver类。

我在浏览亚马逊java文件时发现了这一点,并看到它的BroadcastReceiver正在扩展它。在android-suppotv4.jar上使用jar tf显示这个类不存在。我将android-support-v13.jar添加到我的项目中。确保我的课程路径在Manifest中是正确的,问题得到了解决。