Question

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?

Was it helpful?

Solution

XmlPullParserFactory ppf = new XmlPullParserFactory.newInstance();

should be

XmlPullParserFactory ppf = XmlPullParserFactory.newInstance();

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top