[Solved] Android App Crushing Unexpectedly [closed]


Since you are using Arrays.asList to create your list, this list is unmodifiable, you cannot add or delete any element.

Arrays.asList: Returns a fixed-size list backed by the specified
array.

So when you get to the line

facts.remove(randomNumber);

you get an Exception like the following (just guessing because you have not shared any stacktrace or logs):

Exception in thread "main" java.lang.UnsupportedOperationException
    at java.util.AbstractList.remove(AbstractList.java:161)
    at blah.FactBook.getFact(FactBook.java:131)
    ...

To make your list modifiable create a new List object from the Arrays.asList, e.g.

facts = new ArrayList<String>(Arrays.asList("If you somehow found a way to extract all..."));

1

solved Android App Crushing Unexpectedly [closed]