java-无法实例化接收器GCMBroadcastReceiver

java-无法实例化接收器GCMBroadcastReceiver,第1张

概述我正在遵循http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/的GCM指南.目前,我在接收通知方面陷入困境.有时,当我运行代码时,它会因以下错误而崩溃:7.517:E/AndroidRuntime(8601):FATALEXCEPTION:main

我正在遵循http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/的GCM指南.

目前,我在接收通知方面陷入困境.
有时,当我运行代码时,它会因以下错误而崩溃:

7.517: E/AndroIDRuntime(8601): FATAL EXCEPTION: main
7.517: E/AndroIDRuntime(8601): java.lang.RuntimeException: Unable to instantiate receiver com.Google.androID.gcm.GCMbroadcastReceiver: java.lang.classNotFoundException: DIDn’t find class “com.Google.androID.gcm.GCMbroadcastReceiver” on path: DexPathList[[zip file “/data/app/com.example.someactivity-1.apk”],nativelibraryDirectorIEs=[/data/app-lib/com.example.someactivity-1, /vendor/lib, /system/lib]]
7.517: E/AndroIDRuntime(8601): at androID.app.ActivityThread.handleReceiver(ActivityThread.java:2544)
7.517: E/AndroIDRuntime(8601): at androID.app.ActivityThread.access$1500(ActivityThread.java:153)
7.517: E/AndroIDRuntime(8601): at androID.app.ActivityThread$H.handleMessage(ActivityThread.java:1345)
7.517: E/AndroIDRuntime(8601): at androID.os.Handler.dispatchMessage(Handler.java:99)
7.517: E/AndroIDRuntime(8601): at androID.os.Looper.loop(Looper.java:137)
7.517: E/AndroIDRuntime(8601): at androID.app.ActivityThread.main(ActivityThread.java:5295)
7.517: E/AndroIDRuntime(8601): at java.lang.reflect.Method.invokeNative(Native Method)
7.517: E/AndroIDRuntime(8601): at java.lang.reflect.Method.invoke(Method.java:525)
7.517: E/AndroIDRuntime(8601): at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
7.517: E/AndroIDRuntime(8601): at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:555)
7.517: E/AndroIDRuntime(8601): at dalvik.system.NativeStart.main(Native Method)
7.517: E/AndroIDRuntime(8601): Caused by: java.lang.classNotFoundException: DIDn’t find class “com.Google.androID.gcm.GCMbroadcastReceiver” on path: DexPathList[[zip file “/data/app/com.example.someactivity-1.apk”],nativelibraryDirectorIEs=[/data/app-lib/com.example.someactivity-1, /vendor/lib, /system/lib]]
7.517: E/AndroIDRuntime(8601): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
7.517: E/AndroIDRuntime(8601): at java.lang.classLoader.loadClass(ClassLoader.java:501)
7.517: E/AndroIDRuntime(8601): at java.lang.classLoader.loadClass(ClassLoader.java:461)
7.517: E/AndroIDRuntime(8601): at androID.app.ActivityThread.handleReceiver(ActivityThread.java:2539)

这是我的清单:

<?xml version="1.0" enCoding="utf-8"?><manifest xmlns:androID="http://schemas.androID.com/apk/res/androID"    package="com.example.someactivity"    androID:versionCode="1"    androID:versionname="1.0" >    <uses-sdk        androID:minSdkVersion="14"        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="com.example.someactivity.permission.C2D_MESSAGE"        androID:protectionLevel="signature" />    <uses-permission androID:name="com.example.someactivity.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/theme.Sherlock.light" >        <activity            androID:name="com.example.someactivity.Login"            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.example.someactivity.fragmentContainer" >        </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="com.example.someactivity" />            </intent-filter>        </receiver>        <service androID:name=".GcmIntentService" />    </application></manifest>     

我使用的接收器

private final broadcastReceiver mHandleMessageReceiver = new broadcastReceiver() {    @OverrIDe    public voID onReceive(Context context, Intent intent) {        String newMessage = intent.getExtras().getString("Some Message");        // Waking up mobile if it is sleePing        WakeLocker.acquire(getApplicationContext());        /**         * Take appropriate action on this message         * depending upon your app requirement         * For Now i am just displaying it on the screen         * */        // Showing received message               Toast.makeText(getApplicationContext(), "New Message: " + newMessage, Toast.LENGTH_LONG).show();        // Releasing wake lock        WakeLocker.release();    }};

为什么我的接收器未实例化,我已经更改了程序包名称.

解决方法:

将gcm.jar添加到您的libs文件夹.

总结

以上是内存溢出为你收集整理的java-无法实例化接收器GCMBroadcastReceiver全部内容,希望文章能够帮你解决java-无法实例化接收器GCMBroadcastReceiver所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1087453.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存