尝试向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();
}
答案 0 :(得分:0)
问题是您的AVD必须拥有Google API Target。 你必须配置一个谷歌帐户