android中获取google-calendar的过程sax错误地解决方法

       在使用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=


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值