嗨我尝试从我的应用程序向谷歌日历添加一个事件。它将事件添加到谷歌日历,但它给用户界面“应用程序已意外停止。请再试一次。”
代码在这里:
myService.setUserCredentials(userName, userPassword);
Log.d("debug", "Login accepted ");
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd'T'HHmmss");
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
DateTime startTime = null;
DateTime endTime=null;
try {
startTime = new DateTime(sdf.parse(DTSTART), TimeZone.getDefault());
endTime = new DateTime(sdf.parse(DTEND), TimeZone.getDefault());
Log.d("debug", "Time set Ok");
}
catch (ParseException e) {
// TODO Auto-generated catch block
Log.e("My Error", e.toString());
e.printStackTrace();
}
URL postUrl =
new URL("http://www.google.com/calendar/feeds/"+userName+"/private/full");
CalendarEventEntry myEntry = new CalendarEventEntry();
myEntry.setTitle(new PlainTextConstruct(SUMMARY));
myEntry.setContent(new PlainTextConstruct(DESCRIPTION));
When eventTimes = new When();
eventTimes.setStartTime(startTime);
eventTimes.setEndTime(endTime);
myEntry.addTime(eventTimes);
// Send the request and receive the response:
CalendarEventEntry insertedEntry = myService.insert(postUrl, myEntry);
LogCat响应是:
07-17 12:04:04.518: ERROR/dalvikvm(760): Could not find method javax.xml.parsers.SAXParserFactory.getSchema, referenced from method com.google.gdata.util.common.xml.parsing.SecureGenericXMLFactory$SecureSAXParserFactory.getSchema
07-17 12:04:04.528: WARN/dalvikvm(760): VFY: unable to resolve virtual method 16278: Ljavax/xml/parsers/SAXParserFactory;.getSchema ()Ljavax/xml/validation/Schema;
07-17 12:04:04.528: WARN/dalvikvm(760): VFY: rejecting opcode 0x6e at 0x0002
07-17 12:04:04.528: WARN/dalvikvm(760): VFY: rejected Lcom/google/gdata/util/common/xml/parsing/SecureGenericXMLFactory$SecureSAXParserFactory;.getSchema ()Ljavax/xml/validation/Schema;
07-17 12:04:04.528: WARN/dalvikvm(760): Verifier rejected class Lcom/google/gdata/util/common/xml/parsing/SecureGenericXMLFactory$SecureSAXParserFactory;
07-17 12:04:04.528: WARN/dalvikvm(760): threadid=15: thread exiting with uncaught exception (group=0x4000fe70)
07-17 12:04:04.538: ERROR/AndroidRuntime(760): Uncaught handler: thread Thread-8 exiting due to uncaught exception
07-17 12:04:04.547: ERROR/AndroidRuntime(760): java.lang.VerifyError: com.google.gdata.util.common.xml.parsing.SecureGenericXMLFactory$SecureSAXParserFactory
07-17 12:04:04.547: ERROR/AndroidRuntime(760): at com.google.gdata.util.common.xml.parsing.SecureGenericXMLFactory.getSAXParserFactory(SecureGenericXMLFactory.java:51)
07-17 12:04:04.547: ERROR/AndroidRuntime(760): at com.google.gdata.util.XmlParser.getSAXParserFactory(XmlParser.java:90)
07-17 12:04:04.547: ERROR/AndroidRuntime(760): at com.google.gdata.util.XmlParser.parse(XmlParser.java:679)
07-17 12:04:04.547: ERROR/AndroidRuntime(760): at com.google.gdata.util.XmlParser.parse(XmlParser.java:576)
07-17 12:04:04.547: ERROR/AndroidRuntime(760): at com.google.gdata.data.BaseEntry.parseAtom(BaseEntry.java:1015)
07-17 12:04:04.547: ERROR/AndroidRuntime(760): at com.google.gdata.wireformats.input.AtomDataParser.parse(AtomDataParser.java:59)
07-17 12:04:04.547: ERROR/AndroidRuntime(760): at com.google.gdata.wireformats.input.AtomDataParser.parse(AtomDataParser.java:39)
07-17 12:04:04.547: ERROR/AndroidRuntime(760): at com.google.gdata.wireformats.input.CharacterParser.parse(CharacterParser.java:100)
07-17 12:04:04.547: ERROR/AndroidRuntime(760): at com.google.gdata.wireformats.input.XmlInputParser.parse(XmlInputParser.java:52)
07-17 12:04:04.547: ERROR/AndroidRuntime(760): at com.google.gdata.wireformats.input.AtomDualParser.parse(AtomDualParser.java:66)
07-17 12:04:04.547: ERROR/AndroidRuntime(760): at com.google.gdata.wireformats.input.AtomDualParser.parse(AtomDualParser.java:34)
07-17 12:04:04.547: ERROR/AndroidRuntime(760): at com.google.gdata.client.Service.parseResponseData(Service.java:2165)
07-17 12:04:04.547: ERROR/AndroidRuntime(760): at com.google.gdata.client.Service.parseResponseData(Service.java:2098)
07-17 12:04:04.547: ERROR/AndroidRuntime(760): at com.google.gdata.client.Service.insert(Service.java:1410)
07-17 12:04:04.547: ERROR/AndroidRuntime(760): at com.google.gdata.client.GoogleService.insert(GoogleService.java:606)
07-17 12:04:04.547: ERROR/AndroidRuntime(760): at com.mygoogle.GoogleCalendarActivity$GcalUpload.run(GoogleCalendarActivity.java:355)
07-17 12:04:04.547: ERROR/AndroidRuntime(760): at java.lang.Thread.run(Thread.java:1058)
如何解决这个问题?
答案 0 :(得分:0)
您可以使用GoogleApiJavaClient吗? 看到这里原因: http://code.google.com/p/gdata-java-client/wiki/MigratingToGoogleApiJavaClient