[英]Android: XmlPullParserFactory.newInstance says cannot find symbol class newInstance
I'm trying to parse XML document using XmlPullParser
but I've the following error 我正在尝试使用
XmlPullParser
解析XML文档,但是出现以下错误
Gradle: error: cannot find symbol class newInstance
Creating XmlPullParserFactory
创建
XmlPullParserFactory
XmlPullParserFactory ppf = new XmlPullParserFactory.newInstance();
How to configure Gradle
to discover XmlPullParser
properly? 如何配置
Gradle
以正确发现XmlPullParser
?
XmlPullParserFactory ppf = new XmlPullParserFactory.newInstance();
should be 应该
XmlPullParserFactory ppf = XmlPullParserFactory.newInstance();
You must use new
to invoke constructors, not static methods. 您必须使用
new
来调用构造函数,而不是静态方法。
You just have to remove the new
keyword from your statement that's all. 您只需要从语句中删除
new
关键字即可。
Because new
is basically used to create object via calling the constructor of the your class and in this case we are creating a new instance of PullParserFactory
using newInstance()
method and we are calling this method so we do not need to use this. 因为
new
基本上是用于通过调用类的构造函数来创建对象的,所以在这种情况下,我们将使用newInstance()
方法创建PullParserFactory
的新实例,并且正在调用此方法,因此我们不需要使用它。
And The factory will always return instances of KXmlParser
and KXmlSerializer
. 并且工厂将始终返回
KXmlParser
和KXmlSerializer
实例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.