Open the application. Shortly after loading the home page, the application will crash with the following LogCat message:
java.lang.IllegalArgumentException: n <= 0: 0
at java.util.Random.nextInt(Random.java:182)
at com.google.developer.udacityalumni.service.AlumIntentService.addArticles(AlumIntentService.java:55)
at com.google.developer.udacityalumni.service.AlumIntentService.onHandleIntent(AlumIntentService.java:109)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.os.HandlerThread.run(HandlerThread.java:61)
Other Information
The problem appears to be caused on this line in AlumIntentService:
JSONArray tags = article.getJSONArray(KEY_TAGS);
int ind = new Random().nextInt(tags.length());
If tags has a length of zero, then the application crashes as the nextInt() method in Random cannot accept zero as an argument.
Checking the JSON file at http://udacity-alumni-api.herokuapp.com/api/v1/articles shows what's likely causing the problem (note the empty tags array):
Steps to reproduce
Open the application. Shortly after loading the home page, the application will crash with the following LogCat message:
Other Information
The problem appears to be caused on this line in
AlumIntentService
:If
tags
has a length of zero, then the application crashes as thenextInt()
method inRandom
cannot accept zero as an argument.Checking the JSON file at
http://udacity-alumni-api.herokuapp.com/api/v1/articles
shows what's likely causing the problem (note the empty tags array):