有人可以帮我解决这个问题,我面临的问题是什么,为什么我会遇到这种错误。
UALib:PackageManager不知道com.google.android.c2dm.permission.RECEIVE所需的权限。
我正在使用android urbanirship SDK进行推送通知,在模拟器上运行。它没有给PUSH APID:
the manifest file looks like this
<?xml version="1.0" encoding="utf-8"?>enter code here
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0" package="com.younix.push.sample">
<!-- minSdkVersion sets runtime compatibility ("will run on API level 4") -->
<!-- targetSdkVersion should be set to the latest version tested, to disable compatibility modes
("was tested with API level 9 features") -->
<uses-sdk android:minSdkVersion="4"
android:targetSdkVersion="9"/>
<!-- REQUIRED PERMISSIONS (for Urban Airship GCM) -->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS" /><!-- GCM requires a Google account. -->
<uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- Keeps the processor from sleeping when a message is received. -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /><!-- This app has permission to register with GCM and receive message -->
<!-- MODIFICATION REQUIRED - Replace "com.urbanairship.push.sample" with your package name -->
<permission android:name="com.younix.push.sample.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.younix.push.sample.permission.C2D_MESSAGE" />
<!-- The two elements above ensure that only this application can receive the messages and registration result -->
<!-- END Urban Airship Required Permissions -->
<!-- OPTIONAL Urban Airship Settings -->
<!-- REQUIRED FOR LOCATION -->
<!-- Use ACCESS_COARSE_LOCATION if GPS access is not necessary -->
<!-- uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- OPTIONAL - This permission is only necessary if your app has multiple processes -->
<!-- <uses-permission android:name="android.permission.BROADCAST_STICKY" /> -->
<!-- END OPTIONAL Urban Airship Settings -->
<application android:label="@string/app_name"
android:icon="@drawable/icon"
android:name="com.younix.push.sample.MyApplication"
android:debuggable="true"
android:allowClearUserData="true"
android:enabled="true">
<activity android:name="com.younix.push.sample.MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.younix.push.sample.PushPreferencesActivity" />
<activity android:name="com.younix.push.sample.LocationActivity" />
<!-- REQUIRED for Urban Airship GCM-->
<receiver android:name="com.urbanairship.CoreReceiver" />
<receiver android:name="com.urbanairship.push.GCMPushReceiver" 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" />
<!-- MODIFICATION REQUIRED - Use your package name as the category -->
<category android:name="com.younix.push.sample" />
</intent-filter>
</receiver>
<service android:name="com.urbanairship.push.PushService" android:label="Push Notification Service"/>
<service android:name="com.urbanairship.push.PushWorkerService" android:label="Push Notification Worker Service"/>
<service android:name="com.urbanairship.analytics.EventService" android:label="Event Service"/>
<!-- This is required for persisting preferences related to push and location -->
<provider android:name="com.urbanairship.UrbanAirshipProvider"
android:authorities="com.younix.push.sample.urbanairship.provider"
android:exported="false"
android:multiprocess="true" />
<!-- END OF REQUIRED ITEMS -->
<!-- OPTIONAL (for segments support) -->
<service android:name="com.urbanairship.location.LocationService" android:label="Segments Service"/>
<!-- OPTIONAL, if you want to receive push, push opened and registration completed intents -->
<!-- Replace the receiver below with your package and class name -->
<receiver android:name="com.younix.push.sample.IntentReceiver" />
</application>
</manifest>
Logcat看起来像这样
12-06 11:27:51.052: D/Push Sample - UALib(848): Airship Take Off! Lib Version: 2.0.2 / App key = *******************
12-06 11:27:51.052: D/Push Sample - UALib(848): In Production? false
12-06 11:27:51.102: E/Push Sample - UALib(848): Required permission com.google.android.c2dm.permission.RECEIVE is unknown to PackageManager.
12-06 11:27:51.702: D/Push Sample - UALib(848): Initializing Push.
12-06 11:27:51.712: D/Push Sample - UALib(848): Initializing Location.
12-06 11:27:51.902: D/Push Sample - UALib(848): Location or background location are not enabled - deferring service start until foreground event.
12-06 11:27:51.902: D/Push Sample - UALib(848): Initializing Analytics.
12-06 11:27:52.102: D/Push Sample APID(848): null
12-06 11:27:52.222: V/Push Sample - UALib(848): New session: e9889d8c-e8c8-40b6-a3af-75987c61c55a
12-06 11:27:52.322: V/Push Sample - UALib(848): com.urbanairship.analytics.AppForegroundEvent - {"data":{"time_zone":19800,"session_id":"e9889d8c-e8c8-40b6-a3af-75987c61c55a","notification_types":["sound","vibrate"],"daylight_savings":false,"carrier":"Android","lib_version":"2.0.2","connection_type":"cell","package_version":"1.0","os_version":"4.1.2","connection_subtype":"UMTS"},"type":"app_foreground","event_id":"2e12ccce-0c4b-40fd-9c44-e5dd8401b0a5","time":"1354773472"}
12-06 11:27:52.332: V/Push Sample - UALib(848): com.urbanairship.analytics.ActivityStartedEvent - {"data":{"class_name":"com.younix.push.sample.MainActivity","session_id":"e9889d8c-e8c8-40b6-a3af-75987c61c55a"},"type":"activity_started","event_id":"e8739e18-5d22-4064-b416-ce5002fcba1b","time":"1354773472"}
12-06 11:27:52.332: I/Push Sample - UALib(848): Service is not bound
12-06 11:27:52.382: D/Push Sample - UALib(848): Push Service started with intent=Intent { act=com.urbanairship.push.START cmp=com.younix.push.sample/com.urbanairship.push.PushService }
12-06 11:27:52.412: E/Push Sample - UALib(848): Push enabled: false
12-06 11:27:52.422: V/Push Sample - UALib(848): Push is disabled. Not starting Push Service.
12-06 11:27:52.473: V/Push Sample - UALib(848): com.younix.push.sample.urbanairship.analytics.APP_FOREGROUND
12-06 11:27:52.662: D/dalvikvm(848): GC_CONCURRENT freed 223K, 4% free 8183K/8519K, paused 13ms+99ms, total 168ms
12-06 11:27:52.712: V/Push Sample - UALib(848): Push Service destroyed
12-06 11:27:52.782: D/gralloc_goldfish(848): Emulator without GPU emulation detected.
12-06 11:27:53.542: V/Push Sample - UALib(848): EventService startService
12-06 11:27:53.842: V/Push Sample - UALib(848): EventService startService
12-06 11:28:52.103: V/Push Sample - UALib(848): Next upload time is in the past. Not scheduling a future upload.
12-06 11:28:52.442: D/Push Sample - UALib(848): Notifying of change to content://com.younix.push.sample.urbanairship.provider/preferences/com.urbanairship.analytics.LAST_SEND/insert
12-06 11:28:52.454: V/Push Sample - UALib(848): Notified of change of key com.urbanairship.analytics.LAST_SEND
12-06 11:28:52.522: I/Push Sample - UALib(848): Sending 2 events.
12-06 11:28:52.562: V/Push Sample - UALib(848): Set Timeout: 60000
12-06 11:28:52.562: V/Push Sample - UALib(848): Set Socket Buffer Size: 16384
12-06 11:28:52.572: V/Push Sample - UALib(848): GZIP'd: 592 into 352 (expected 148)
12-06 11:28:52.642: I/Push Sample - UALib(848): Sending Analytics to: https://combine.urbanairship.com/warp9/
12-06 11:28:56.252: I/Push Sample - UALib(848): Warp 9 response: 200
12-06 11:28:56.352: D/Push Sample - UALib(848): Notifying of change to content://com.younix.push.sample.urbanairship.provider/preferences/com.urbanairship.analytics.MAX_TOTAL_DB_SIZE/insert
12-06 11:28:56.362: V/Push Sample - UALib(848): Notified of change of key com.urbanairship.analytics.MAX_TOTAL_DB_SIZE
12-06 11:28:56.423: D/Push Sample - UALib(848): Notifying of change to content://com.younix.push.sample.urbanairship.provider/preferences/com.urbanairship.analytics.MAX_BATCH_SIZE/insert
12-06 11:28:56.432: V/Push Sample - UALib(848): Notified of change of key com.urbanairship.analytics.MAX_BATCH_SIZE
12-06 11:28:56.483: D/Push Sample - UALib(848): Notifying of change to content://com.younix.push.sample.urbanairship.provider/preferences/com.urbanairship.analytics.MAX_WAIT/insert
12-06 11:28:56.492: V/Push Sample - UALib(848): Notified of change of key com.urbanairship.analytics.MAX_WAIT
12-06 11:28:56.572: D/Push Sample - UALib(848): Notifying of change to content://com.younix.push.sample.urbanairship.provider/preferences/com.urbanairship.analytics.MIN_BATCH_INTERVAL/insert
有关正在发生的事情或我忘记添加到项目中的任何提示?
答案 0 :(得分:5)
嗨,我遇到了同样的问题。解决方案很简单。只需创建一个支持Google API的新模拟器。它将存在于您的虚拟管理器中。这就是问题:)