1

我在尝试注册 GCM 时收到此错误。我的 AVD 目标是 Android 4.2.2,API 级别是 17。使用 SGS3 4.2.2 工作正常,Galaxy GT-I9003 和所有版本的模拟器都不起作用。我已经在正确的文件夹中导入了所有库。如果有人可以帮助我们,请写出解决方案!

07-22 16:09:02.023: W/System.err(12698): java.io.IOException: SERVICE_NOT_AVAILABLE
07-22 16:09:02.023: W/System.err(12698):    at com.google.android.gms.gcm.GoogleCloudMessaging.register(Unknown Source)
07-22 16:09:02.023: W/System.err(12698):    at appgelato.ui.HomeActivity$5.doInBackground(HomeActivity.java:237)
07-22 16:09:02.031: W/System.err(12698):    at appgelato.ui.HomeActivity$5.doInBackground(HomeActivity.java:1)
07-22 16:09:02.031: W/System.err(12698):    at android.os.AsyncTask$2.call(AsyncTask.java:185)
07-22 16:09:02.039: W/System.err(12698):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
07-22 16:09:02.039: W/System.err(12698):    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
07-22 16:09:02.039: W/System.err(12698):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
07-22 16:09:02.039: W/System.err(12698):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
07-22 16:09:02.039: W/System.err(12698):    at java.lang.Thread.run(Thread.java:1019)

我的代码是:

try {
                    if (gcm == null) {
                        gcm = GoogleCloudMessaging.getInstance(context);
                    }
                    while (regid.equals("")) {
                        regid = gcm.register(SENDER_ID); //STOP HERE AND CALL EXCEPTION
                        msg = "Device registered, registration id=" + regid;
                        setRegistrationId(context, regid);
                    }
                    Controller.setDeviceToken(regid);

                } catch (IOException ex) {
                    ex.printStackTrace();
                    msg = "Error :" + ex.getMessage();

                }
4

1 回答 1

0

问题是您的 AVD 必须具有 Google API 的目标。并且您必须配置一个 google 帐户

于 2013-09-30T14:37:02.147 回答