AndroidFillableLoaders icon indicating copy to clipboard operation
AndroidFillableLoaders copied to clipboard

github.jorgecastillo.svg.SvgPathParser.ParsePath()

Open reema07 opened this issue 6 years ago • 15 comments

I am new in Android Studio Development

could you please guide me how to resolve this error to find the null point of string path error in SvgPathParser class parsePath() function pathstring not found.

reema07 avatar May 28 '18 06:05 reema07

I have same issues.I could not solve it.

aligkts avatar Feb 26 '19 13:02 aligkts

Can you2 paste some code producing this or what did you follow when this appeared?

Letme avatar Feb 26 '19 15:02 Letme

(I am not on computer but lets get more info).

Can you print/share the value of you path (SvgPath.Bag.path)? It seems like that is NULL...

Letme avatar Feb 26 '19 16:02 Letme

(your replies are a bit messed since you reply on mails)

Ok, so since public FillableLoaderBuilder svgPath(String svgPath) takes String and you feed it with val we can start with that alignment. Here I assume that path contains something like string with "\n" for end of line characters, some string numbers with dots and stuff (so not OS path)...

Letme avatar Feb 26 '19 16:02 Letme

Yes my path contains "\n" and "+".What do you think?

aligkts avatar Feb 26 '19 16:02 aligkts

Did you try to change the path variable from val to String? It seems like the length is somehow null and that hits the null pointer exception.

Letme avatar Feb 26 '19 19:02 Letme

It is already 'val path: String?' when I change it to 'path: String?',this does not refers path 'val path= SvgPath.Bag.path'

aligkts avatar Feb 26 '19 19:02 aligkts

I would indeed change val path= SvgPath.Bag.path to String path= SvgPath.Bag.path to make it more explicit. You confirmed with debugger that path then contains a proper string which is passed to svgPath()? Just go step by step with break points if logcat print messages are not revealing enough.

Letme avatar Feb 26 '19 19:02 Letme

In Kotlin language, val path= SvgPath.Bag.path refers to Java's String path= SvgPath.Bag.path

aligkts avatar Feb 26 '19 19:02 aligkts

Path does not comes null I checked that but I have no idea about what is the problem :(

aligkts avatar Feb 26 '19 19:02 aligkts

Kotlin... huh I am indeed rusty. Can you again paste the LogCat error and a nicely formatted example? I was on Java, but this might be issue with Kotlin calling Java?

Letme avatar Feb 26 '19 19:02 Letme

java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference at com.github.jorgecastillo.svg.SvgPathParser.parsePath(SvgPathParser.java:52) at com.github.jorgecastillo.FillableLoader.buildPathData(FillableLoader.java:374) at com.github.jorgecastillo.FillableLoader.onSizeChanged(FillableLoader.java:224)

this is LogCat error

aligkts avatar Feb 26 '19 19:02 aligkts

So the error reads exactly what I said, but what you pasted before was .build() method - so I assume logcat marks that line as failure in your application? You will have to give a lot more information if you want me to help you debug this, because now I can only guess.

Letme avatar Feb 26 '19 23:02 Letme

https://gist.github.com/aligkts/94722473e34f55b812c56ca1977f3b37 https://gist.github.com/aligkts/2f3c1f5ef55ba594fd84dad3d2adb99b https://gist.github.com/aligkts/560b8c1da5b1a743fde3f8c8d3c93e50

You can check it from these links easily.

aligkts avatar Feb 27 '19 06:02 aligkts

OK few ideas (remember don't know Kotlin syntax or background so might be totally off):

  • I assume you confirmed without this lines the fragment loads (put a textview in to start with), because I remember you have to inflate fragments and stuff like that
  • Maybe a simple var string instead of enum class would do the trick (although I read over Kotlin help on enum class and it should return String like you say it does)
  • For future you are missing fillableLoader.setOnStateChangeListener(this); later on, because I see your error originates from: com.github.jorgecastillo.FillableLoader.onSizeChanged(FillableLoader.java:224), which might also be something coming from onStateChange trigger in second loop (error is kinda short and does not map to your code so I am guessing again).

Letme avatar Feb 27 '19 08:02 Letme