在使用android调用google-calendar的过程中会出现java.lang.NoClassDefFoundError: com.google.gdata.util.common.xml.parsing.SecureGenericXMLFactory的错误,经过网上查找终于找到了相应的解决方法:
1、首先对gdata-core-1.0.jar包中的删掉com/google/gdata/util/common/xml/parsing路径下的文件夹(parsing),然后重新打成jar包并删掉以前的,进行替换引用。
2、在google-calendar的代码中找到SecureSAXParserFactory类,路径为com.google.gdata.util.common.xml.parsing
2、在自己的工程中新建包com.google.gdata.util.common.xml.parsing,并将类SecureGenericXMLFactory考到此路径下,进行修改,将构造函数修改为if(true)的形式
if (true)
{
return;
}
SecureGenericXMLFactory的构造函数修改后的代码如下:
/**
* Constructs a new SecureSAXParserFactory instance that delegates
* most functionality to an existing instance, but overrides where
* needed to protect against XXE attacks.
*
* @param factory the existing SAXParserFactory that should be secured.
* @throws ParserConfigurationException on configuration errors.
* @throws SAXException on configuration failures.
*/
protected SecureSAXParserFactory(SAXParserFactory factory)
throws ParserConfigurationException, SAXException {
this.factory = factory;
/* Since we disable DTDs, we can't be validating. */
if(true)
return;
}
下面是查找的一些资料:
http://darutk-oboegaki.blogspot.com/2011/11/solution-for-gdata-java-clients.html
http://code.google.com/p/android/issues/detail?id=9493
google-calendar源代码的下载地址:http://code.google.com/p/gdata-java-client/downloads/detail?name=gdata-src.java-1.46.0.zip&can=2&q=