Skip to content Skip to sidebar Skip to footer

Android Jsoup - Nullpointerexception When Parsing Images

I am using Jsoup in my Android app to get images from the internet but an getting a NullPointerException. Java: public class CollegeInfo extends Activity{ TextView body; ImageVie

Solution 1:

Look at your stacktrace:

07-2917:19:49.985: E/AndroidRuntime(10855): Caused by: java.lang.NullPointerException
07-2917:19:49.985: E/AndroidRuntime(10855):    at com.collegeselector.CollegeInfo.onCreate(CollegeInfo.java:87)

You haven't initialized the string array String[] imgSrcs; yet you try to add content to it in your for each loop:

imgSrcs[i] = img.text();

Also, the size of an array cannot be modified, so you either decide upon a size of it when you initialize it and then stick with it. If you want a dynamic size, use an ArrayList object instead.

Post a Comment for "Android Jsoup - Nullpointerexception When Parsing Images"