Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
169 views
in Technique[技术] by (71.8m points)

android - New GCM API Register Unknown Source Error

I am currently building an application that uses the new Google Cloud Messaging system. I have a HTTP client server set up on a live environment to allow me to test through my mobile devices, but when ever I try to register with the GCM I keep getting a IOException that states that gcm.register() is receiving an Unknown Source stopping me from getting the Registration Id I need to allow my server send messages to my device.

I have checked several times to see if my Sender Id is wrong and I have checked over my manifest as well to see if I have that wrong as well and I cannot seem to find the problem. Looking around also hasn't provided any answer to my problem.

Here is my Log:

07-18 11:34:25.487: W/System.err(3093): java.io.IOException: MAIN_THREAD
07-18 11:34:25.497: W/System.err(3093):     at com.google.android.gms.gcm.GoogleCloudMessaging.register(Unknown Source)
07-18 11:34:25.497: W/System.err(3093):     at koodoo.pushtest.MainActivity.onCreate(MainActivity.java:94)
07-18 11:34:25.497: W/System.err(3093):     at android.app.Activity.performCreate(Activity.java:4492)
07-18 11:34:25.497: W/System.err(3093):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
07-18 11:34:25.497: W/System.err(3093):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
07-18 11:34:25.497: W/System.err(3093):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
07-18 11:34:25.497: W/System.err(3093):     at android.app.ActivityThread.access$600(ActivityThread.java:123)
07-18 11:34:25.497: W/System.err(3093):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
07-18 11:34:25.497: W/System.err(3093):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-18 11:34:25.497: W/System.err(3093):     at android.os.Looper.loop(Looper.java:137)
07-18 11:34:25.497: W/System.err(3093):     at android.app.ActivityThread.main(ActivityThread.java:4424)
07-18 11:34:25.497: W/System.err(3093):     at java.lang.reflect.Method.invokeNative(Native Method)
07-18 11:34:25.497: W/System.err(3093):     at java.lang.reflect.Method.invoke(Method.java:511)
07-18 11:34:25.497: W/System.err(3093):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
07-18 11:34:25.497: W/System.err(3093):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
07-18 11:34:25.497: W/System.err(3093):     at dalvik.system.NativeStart.main(Native Method)

Here is my Manifest:

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

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <!-- GCM connects to Internet Services. -->
    <uses-permission android:name="android.permission.INTERNET" />

    <!-- GCM requires a Google account. -->
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />

    <!-- Keeps the processor from sleeping when a message is received. -->
    <uses-permission android:name="android.permission.WAKE_LOCK" />

    <!-- Creates a custom permission so only this app can receive its messages. -->
    <permission
        android:name="koodoo.pushtest.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />

    <uses-permission android:name="koodoo.pushtest.permission.C2D_MESSAGE" />

    <!-- This app has permission to register and receive data message. -->
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

    <!-- Network State Permissions to detect Internet status -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <!-- Permission to vibrate -->
    <uses-permission android:name="android.permission.VIBRATE" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="koodoo.pushtest.MainActivity"
            android:label="@string/app_name" >

        </activity>

        <receiver
            android:name="com.google.android.gcm.GCMBroadcastReceiver"
            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="koodoo.pushtest" />
            </intent-filter>
        </receiver>

        <service android:name="com.google.android.gcm.GCMIntentService" />

        <activity
            android:name="koodoo.pushtest.RegisterActivity"
            android:label="@string/title_activity_register" >

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Any help to fix this would be greatly appreciated.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...