문제

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