1

所以,我基本上是按照这个教程一步一步来的 http://developer.android.com/guide/google/gcm/demo.html 我让服务器给了我“没有注册设备!” 我所要做的就是启动应用程序,这就是我的问题开始的地方。日志猫注册:

"Trace - error opening trace file: no such file or directory (2)
AndroidRunTime - Shutting Down VM
dalvikvm - threadid=1: thread exiting with uncaught exception (group=0x40a13300)
AndroidRunTime - FATAL EXCEPTION: main"

显现:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.google.android.gcm.demo.app"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16"/>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <permission
        android:name="com.google.android.gcm.demo.app.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />
    <uses-permission
        android:name="com.google.android.gcm.demo.app.permission.C2D_MESSAGE" />
    <uses-permission
        android:name="com.google.android.c2dm.permission.RECEIVE" />

    <!-- Main activity. -->
    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".DemoActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </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.google.android.gcm.demo.app" />
            </intent-filter>
        </receiver>

        <service android:name=".GCMIntentService" />
    </application>

</manifest>

顺便说一句,我导入了项目以确保问题不是来自我糟糕的编程。

4

3 回答 3

0

确保它是 Google API 模拟器。还可以在模拟器中使用 gmail 帐户登录。

于 2012-10-10T11:27:37.727 回答
0

要在模拟器上运行 GCM,您需要在模拟器上创建 google 帐户。你创造了吗?模拟器显示仅在成功执行时显示 Logcat 中的消息

于 2012-10-10T11:21:15.783 回答
-1

如果您已遵循 GCM 演示应用程序中的所有指南,则可以使用以下方法捕获未捕获的异常:

import android.content.Context;
import android.os.Process;

public class ExceptionHandler implements UncaughtExceptionHandler{

    public ExceptionHandler() {
    }

    @Override
    public void uncaughtException(Thread thread, Throwable ex) {

            // capture the exception information 

        Process.killProcess(Process.myPid());
        System.exit(0);
    }

  }

在您的主要活动中:

@Override
public void onCreate(Bundle bundle) {

    Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler());
}
于 2012-10-10T11:28:27.483 回答