I'm trying to run the example code given in Getting Started with GCM on the emulator. Nothing fancier than that. Based on what I've read here, I needed to create an emulator running the Google APIs, which I have done.
One thing complicating this, perhaps, is that I'm using the new "Android Studio" tools that Google is distributing.
Anyways, I've modified the code to use my Sender ID but every time so far it's stopped at the gcm.register(SENDER_ID) line in the AsyncTask. It always has the same error:
java.io.IOException: SERVICE_NOT_AVAILABLE
at com.google.android.gms.gcm.GoogleCloudMessaging.register(Unknown Source)
at com.abc.gcmTester.MainActivity$3.doInBackground(MainActivity.java:213)
at com.abc.gcmTester.MainActivity$3.doInBackground(MainActivity.java:205)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
Also, here's the AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.abc.gcmTester"
android:versionCode="1"
android:versionName="1.0" >
<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.abc.gcmTester.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.abc.gcmTester.permission.C2D_MESSAGE"/>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.abc.gcmTester.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>
<receiver
android:name=".MyBroadcastReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<category android:name="com.abc.gcmTester"/>
</intent-filter>
</receiver>
</application>
</manifest>
I can set up Wireshark to trace packet traffic, but I'm not sure what to look for.
I've been digging around here looking for some help but no luck... I think the emulator has the correct library but it's just not happy. Any thoughts?