Frage

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?

War es hilfreich?

Lösung

XmlPullParserFactory ppf = new XmlPullParserFactory.newInstance();

should be

XmlPullParserFactory ppf = XmlPullParserFactory.newInstance();

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

Andere Tipps

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top