问题
As the title indicates I get a TIMEOUT
exception when trying to get token using Google Cloud Messaging on API 10 emulator. I have added my google account on the device, checked that "Sync" is ON, also added the
<action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
in the manifest in the receiver and still cannot find out what is causing this:
11-25 17:35:00.896 29750-29774/com.example.alexis.myapplication W/InstanceID/Rpc: No response android.os.ConditionVariable@b667bc18
11-25 17:35:00.896 29750-29774/com.example.alexis.myapplication E/MYAPP: TIMEOUT
Here is the manifest declaration for permissions:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<permission android:name="com.example.alexis.myapplication.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.example.alexis.myapplication.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
And receiver:
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<!-- Receives the actual messages. -->
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<!-- Receives the registration id. -->
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.example.alexis.myapplication" />
</intent-filter>
</receiver>
Any help would be highly appreciated.
Note: I am using genymotion emulator with 2.3.7, I don't have a hardware device to test.
回答1:
Used a hardware device and everything worked so it was emulator's fault.
来源:https://stackoverflow.com/questions/33923223/android-gcm-instanceid-gettoken-throws-timeout-exception-on-gingerbread