我正在使用以下代码将谷歌日历中的所有提要检索到我的应用程序中。
try{
URL feedUrl = new
URL("https://www.google.com/calendar/feeds/mymailID/public/full");
CalendarService myService = new CalendarService("exampleCo-exampleApp-1");
myService.setUserCredentials("mymailID", "mymailIDpassword");
// Send the request and receive the response:
CalendarEventFeed myFeed = myService.getFeed(feedUrl, CalendarEventFeed.class);
System.out.println("feed:"+myFeed);
}
catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
运行应用程序时出现以下错误。我认为用户凭据有问题,所以我公开了我的日历并尝试运行它,但仍然出现相同的错误。我浏览了几个解决方案,他们建议将 gdata jar 文件放入 libs 文件夹,但是当我这样做时,我得到了一个 dalvik 错误,因为在 android 4.0 中,libs 文件夹包含 android-support-v4.jar,这会弹出一个错误说文件重复。
05-24 13:20:33.129: W/dalvikvm(274): Unable to resolve superclass of Lcom/google/gdata/client/calendar/CalendarService; (537)
05-24 13:20:33.129: W/dalvikvm(274): Link of class 'Lcom/google/gdata/client/calendar/CalendarService;' failed
05-24 13:20:33.139: E/dalvikvm(274): Could not find class 'com.google.gdata.client.calendar.CalendarService', referenced from method com.googlecalendar.googleapi.MainActivity.onCreate
05-24 13:20:33.139: W/dalvikvm(274): VFY: unable to resolve new-instance 546 (Lcom/google/gdata/client/calendar/CalendarService;) in Lcom/googlecalendar/googleapi/MainActivity;
05-24 13:20:33.139: D/dalvikvm(274): VFY: replacing opcode 0x22 at 0x000f
05-24 13:20:33.139: W/dalvikvm(274): VFY: unable to resolve exception class 717 (Lcom/google/gdata/util/ServiceException;)
05-24 13:20:33.139: W/dalvikvm(274): VFY: unable to find exception handler at addr 0x44
05-24 13:20:33.139: W/dalvikvm(274): VFY: rejected Lcom/googlecalendar/googleapi/MainActivity;.onCreate (Landroid/os/Bundle;)V
05-24 13:20:33.139: W/dalvikvm(274): VFY: rejecting opcode 0x0d at 0x0044
05-24 13:20:33.139: W/dalvikvm(274): VFY: rejected Lcom/googlecalendar/googleapi/MainActivity;.onCreate (Landroid/os/Bundle;)V
05-24 13:20:33.139: W/dalvikvm(274): Verifier rejected class Lcom/googlecalendar/googleapi/MainActivity;
05-24 13:20:33.139: W/dalvikvm(274): Class init failed in newInstance call (Lcom/googlecalendar/googleapi/MainActivity;)
05-24 13:20:33.139: D/AndroidRuntime(274): Shutting down VM
05-24 13:20:33.139: W/dalvikvm(274): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
05-24 13:20:33.169: E/AndroidRuntime(274): FATAL EXCEPTION: main
05-24 13:20:33.169: E/AndroidRuntime(274): java.lang.VerifyError: com.googlecalendar.googleapi.MainActivity
05-24 13:20:33.169: E/AndroidRuntime(274): at java.lang.Class.newInstanceImpl(Native Method)
05-24 13:20:33.169: E/AndroidRuntime(274): at java.lang.Class.newInstance(Class.java:1429)
05-24 13:20:33.169: E/AndroidRuntime(274): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
05-24 13:20:33.169: E/AndroidRuntime(274): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
05-24 13:20:33.169: E/AndroidRuntime(274): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-24 13:20:33.169: E/AndroidRuntime(274): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-24 13:20:33.169: E/AndroidRuntime(274): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-24 13:20:33.169: E/AndroidRuntime(274): at android.os.Handler.dispatchMessage(Handler.java:99)
05-24 13:20:33.169: E/AndroidRuntime(274): at android.os.Looper.loop(Looper.java:123)
05-24 13:20:33.169: E/AndroidRuntime(274): at android.app.ActivityThread.main(ActivityThread.java:4627)
05-24 13:20:33.169: E/AndroidRuntime(274): at java.lang.reflect.Method.invokeNative(Native Method)
05-24 13:20:33.169: E/AndroidRuntime(274): at java.lang.reflect.Method.invoke(Method.java:521)
05-24 13:20:33.169: E/AndroidRuntime(274): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-24 13:20:33.169: E/AndroidRuntime(274): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-24 13:20:33.169: E/AndroidRuntime(274): at dalvik.system.NativeStart.main(Native Method)
05-24 13:20:36.480: I/Process(274): Sending signal. PID: 274 SIG: 9
05-24 13:25:02.579: W/dalvikvm(305): Unable to resolve superclass of Lcom/google/gdata/client/calendar/CalendarService; (537)
05-24 13:25:02.579: W/dalvikvm(305): Link of class 'Lcom/google/gdata/client/calendar/CalendarService;' failed
05-24 13:25:02.599: E/dalvikvm(305): Could not find class 'com.google.gdata.client.calendar.CalendarService', referenced from method com.googlecalendar.googleapi.MainActivity.onCreate
05-24 13:25:02.599: W/dalvikvm(305): VFY: unable to resolve new-instance 546 (Lcom/google/gdata/client/calendar/CalendarService;) in Lcom/googlecalendar/googleapi/MainActivity;
05-24 13:25:02.609: D/dalvikvm(305): VFY: replacing opcode 0x22 at 0x000f
05-24 13:25:02.639: W/dalvikvm(305): VFY: unable to resolve exception class 717 (Lcom/google/gdata/util/ServiceException;)
05-24 13:25:02.639: W/dalvikvm(305): VFY: unable to find exception handler at addr 0x44
05-24 13:25:02.649: W/dalvikvm(305): VFY: rejected Lcom/googlecalendar/googleapi/MainActivity;.onCreate (Landroid/os/Bundle;)V
05-24 13:25:02.649: W/dalvikvm(305): VFY: rejecting opcode 0x0d at 0x0044
05-24 13:25:02.649: W/dalvikvm(305): VFY: rejected Lcom/googlecalendar/googleapi/MainActivity;.onCreate (Landroid/os/Bundle;)V
05-24 13:25:02.649: W/dalvikvm(305): Verifier rejected class Lcom/googlecalendar/googleapi/MainActivity;
05-24 13:25:02.649: W/dalvikvm(305): Class init failed in newInstance call (Lcom/googlecalendar/googleapi/MainActivity;)
05-24 13:25:02.649: D/AndroidRuntime(305): Shutting down VM
05-24 13:25:02.649: W/dalvikvm(305): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
05-24 13:25:02.709: E/AndroidRuntime(305): FATAL EXCEPTION: main
05-24 13:25:02.709: E/AndroidRuntime(305): java.lang.VerifyError: com.googlecalendar.googleapi.MainActivity
05-24 13:25:02.709: E/AndroidRuntime(305): at java.lang.Class.newInstanceImpl(Native Method)
05-24 13:25:02.709: E/AndroidRuntime(305): at java.lang.Class.newInstance(Class.java:1429)
05-24 13:25:02.709: E/AndroidRuntime(305): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
05-24 13:25:02.709: E/AndroidRuntime(305): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
05-24 13:25:02.709: E/AndroidRuntime(305): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-24 13:25:02.709: E/AndroidRuntime(305): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-24 13:25:02.709: E/AndroidRuntime(305): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-24 13:25:02.709: E/AndroidRuntime(305): at android.os.Handler.dispatchMessage(Handler.java:99)
05-24 13:25:02.709: E/AndroidRuntime(305): at android.os.Looper.loop(Looper.java:123)
05-24 13:25:02.709: E/AndroidRuntime(305): at android.app.ActivityThread.main(ActivityThread.java:4627)
05-24 13:25:02.709: E/AndroidRuntime(305): at java.lang.reflect.Method.invokeNative(Native Method)
05-24 13:25:02.709: E/AndroidRuntime(305): at java.lang.reflect.Method.invoke(Method.java:521)
05-24 13:25:02.709: E/AndroidRuntime(305): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-24 13:25:02.709: E/AndroidRuntime(305): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-24 13:25:02.709: E/AndroidRuntime(305): at dalvik.system.NativeStart.main(Native Method)
05-24 13:25:05.190: I/Process(305): Sending signal. PID: 305 SIG: 9