I'm trying to parse XML document using XmlPullParser but I've the following error

Gradle: error: cannot find symbol class newInstance

Creating XmlPullParserFactory

XmlPullParserFactory ppf = new XmlPullParserFactory.newInstance();

How to configure Gradle to discover XmlPullParser properly?

有帮助吗?

解决方案

XmlPullParserFactory ppf = new XmlPullParserFactory.newInstance();

should be

XmlPullParserFactory ppf = XmlPullParserFactory.newInstance();

You must use new to invoke constructors, not static methods.

其他提示

You just have to remove the new keyword from your statement that's all.

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.

And The factory will always return instances of KXmlParser and KXmlSerializer.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top