私はこのチュートリアルでC2DMクライアントを使用しようとしています。http://www.vogella.de/articles/AndroidCloudToDeviceMessaging/article.htmlは登録C2DMRegistrar.25:HTTPエラー401
私はこのコードを使用していクライアント(チュートリアルのコードとは少し異なる)のために:私は、パッケージ名をchangued http://www.vogella.de/code/de.vogella.android.c2dm/codestartpage.html
、私は1つ、com.DemoC2DM
に二つのパッケージを合併し、私は新しいの作業コードを取得するには、マニフェストからいくつかの行をchanguedし、クライアントとの登録IDを取得しようとするとこのエラーが発生するため、おそらく私はマニフェストの変更された行に何か間違っています。
01-16 12:45:52.133: ERROR/Super(1517): Starting registration
01-16 12:45:52.375: DEBUG/GoogleLoginService(1226): onBind: Intent { act=android.accounts.AccountAuthenticator cmp=com.google.android.gsf/.loginservice.GoogleLoginService }
01-16 12:45:53.640: DEBUG/dalvikvm(1226): GC_FOR_MALLOC freed 7811 objects/420368 bytes in 53ms
01-16 12:45:53.640: DEBUG/NativeCrypto(1226): Freeing OpenSSL session
01-16 12:45:53.945: WARN/DefaultRequestDirector(1226): Authentication error: Unable to respond to any of these challenges: {}
01-16 12:45:53.945: DEBUG/C2DMRegistrar(1226): [C2DMRegistrar.25] register: http error 401
01-16 12:45:53.945: ERROR/C2DMRegistrar(1226): [C2DMReg] handleRequest caught org.apache.http.auth.AuthenticationException
これは私のマニフェストのコードです:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.DemoC2DM" android:versionCode="1"
android:versionName="1.0">
<permission android:name="com.DemoC2DM.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.DemoC2DM.permission.C2D_MESSAGE" />
<!-- Permissions -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name="RegisterActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name=".C2DMReceiver" />
<!-- Only C2DM servers can send messages for the app. If permission is
not set - any other app can generate it -->
<receiver android:name="com.google.android.c2dm.C2DMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<!-- Receive the actual message -->
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="de.vogella.android.c2dm" />
</intent-filter>
<!-- Receive the registration id -->
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="de.vogella.android.c2dm" />
</intent-filter>
</receiver>
</application>
</manifest>
と、これは私のパッケージを変更せず、元のマニフェストのコードです:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.vogella.android.c2dm" android:versionCode="1"
android:versionName="1.0">
<permission android:name="de.vogella.android.c2dm.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="de.vogella.android.c2dm.permission.C2D_MESSAGE" />
<!-- Permissions -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name="RegisterActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name=".C2DMReceiver" />
<!-- Only C2DM servers can send messages for the app. If permission is
not set - any other app can generate it -->
<receiver android:name="com.google.android.c2dm.C2DMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<!-- Receive the actual message -->
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="de.vogella.android.c2dm" />
</intent-filter>
<!-- Receive the registration id -->
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="de.vogella.android.c2dm" />
</intent-filter>
</receiver>
</application>
</manifest>
EDIT:Sumant変更後に例外を追加します:
01-16 13:16:39.187: DEBUG/C2DMRegistrar(1226): [C2DMRegistrar.25] register: http error 401
01-16 13:16:39.187: ERROR/C2DMRegistrar(1226): [C2DMReg] handleRequest caught org.apache.http.auth.AuthenticationException
01-16 13:16:39.218: DEBUG/GoogleLoginService(1226): onBind: Intent { act=android.accounts.AccountAuthenticator cmp=com.google.android.gsf/.loginservice.GoogleLoginService }
01-16 13:16:39.289: WARN/ActivityManager(1086): Unable to start service Intent { act=com.motorola.motosync.service.intent.action.CHECK_PING flg=0x4 cmp=com.motorola.motosync/.service.EasService (has extras) }: not found
01-16 13:16:39.304: DEBUG/GoogleLoginService(1226): onBind: Intent { act=android.accounts.AccountAuthenticator cmp=com.google.android.gsf/.loginservice.GoogleLoginService }
01-16 13:16:40.218: DEBUG/dalvikvm(1226): GC_FOR_MALLOC freed 8422 objects/453352 bytes in 71ms
01-16 13:16:40.523: DEBUG/AndroidRuntime(1535): Shutting down VM
01-16 13:16:40.523: WARN/dalvikvm(1535): threadid=1: thread exiting with uncaught exception (group=0x4001d7e0)
01-16 13:16:40.539: ERROR/AndroidRuntime(1535): FATAL EXCEPTION: main
01-16 13:16:40.539: ERROR/AndroidRuntime(1535): java.lang.RuntimeException: Unable to instantiate receiver com.google.android.c2dm.C2DMBroadcastReceiver: java.lang.ClassNotFoundException: com.google.android.c2dm.C2DMBroadcastReceiver in loader dalvik.system.PathClassLoader[/data/app/com.DemoC2DM-2.apk]
01-16 13:16:40.539: ERROR/AndroidRuntime(1535): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2789)
01-16 13:16:40.539: ERROR/AndroidRuntime(1535): at android.app.ActivityThread.access$3200(ActivityThread.java:125)
01-16 13:16:40.539: ERROR/AndroidRuntime(1535): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2083)
01-16 13:16:40.539: ERROR/AndroidRuntime(1535): at android.os.Handler.dispatchMessage(Handler.java:99)
01-16 13:16:40.539: ERROR/AndroidRuntime(1535): at android.os.Looper.loop(Looper.java:123)
01-16 13:16:40.539: ERROR/AndroidRuntime(1535): at android.app.ActivityThread.main(ActivityThread.java:4627)
01-16 13:16:40.539: ERROR/AndroidRuntime(1535): at java.lang.reflect.Method.invokeNative(Native Method)
01-16 13:16:40.539: ERROR/AndroidRuntime(1535): at java.lang.reflect.Method.invoke(Method.java:521)
01-16 13:16:40.539: ERROR/AndroidRuntime(1535): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
01-16 13:16:40.539: ERROR/AndroidRuntime(1535): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
01-16 13:16:40.539: ERROR/AndroidRuntime(1535): at dalvik.system.NativeStart.main(Native Method)
01-16 13:16:40.539: ERROR/AndroidRuntime(1535): Caused by: java.lang.ClassNotFoundException: com.google.android.c2dm.C2DMBroadcastReceiver in loader dalvik.system.PathClassLoader[/data/app/com.DemoC2DM-2.apk]
01-16 13:16:40.539: ERROR/AndroidRuntime(1535): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
01-16 13:16:40.539: ERROR/AndroidRuntime(1535): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
01-16 13:16:40.539: ERROR/AndroidRuntime(1535): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
01-16 13:16:40.539: ERROR/AndroidRuntime(1535): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2780)
01-16 13:16:40.539: ERROR/AndroidRuntime(1535): ... 10 more
01-16 13:16:40.562: WARN/ActivityManager(1086): Force finishing activity com.DemoC2DM/.RegisterActivity
、それを確認してください – NullPointerException
ので、あなたのプロジェクトでこのクラスをcom.google.android.c2dm.C2DMBroadcastReceiver見つけることができませんあなたは例外があります。変更を行った後、プロジェクトを一度きれいにしてR.javaファイルを生成してからもう一度チェックしてください – Sumant
私はそれを行い、私はまだ同じ例外を受けています:01-16 14:12:53.156:ERROR/AndroidRuntime(1645):原因:java.lang.ClassNotFoundException:com.google.android.c2dm.C2DMBroadcastReceiver in loader dalvik.system.PathClassLoader [/data/app/com.DemoC2DM-1.apk] – NullPointerException