what does array<(out) string!> mean?
This declaration has a bunch of components to unpack:
Array is the base raw type
String is the the type argument of Array, which in this case is the element type of the array
- The exclamation mark on
String! shows that it is a platform type. This means that this comes from Java and Kotlin doesn't know the nullability of these Strings. Basically, it can't tell you whether the arrays contains nulls or not. When in doubt like this, Kotlin doesn't force you to check the nullability, for convenience.
- the
out modifier on the generic type parameter shows that the array may contain subtypes of String, so you should not be able to update elements in it in theory (you should only be able to get values "out" of the array, and store them in String variables). Kotlin puts parentheses around the (out) because it's inferred from Java (nothing is certain). So in practice you might not be restricted like this, and you should still be able to assign the array to a variable of type Array<String>, and thus insert stuff in it.
In short, Array<(out) String!> means "Java array of Strings (or a subtype of String) which are nullable or not".
Now, I'm not very well versed in Android APIs, but it seems that the assets.list() function you're calling is this one.
This method returns a nullable array Array<out String!>?, so you can't call methods directly on it without checking for the nullability of the array itself. Either use a safe call with ? or check for null before returning:
return soundNames?.toList() // you have to make your return type nullable in this case
Or:
return soundNames?.toList() ?: error("Null assets array")
EDIT
After the edit in the question, it seems that the nullability is now already handled via !! operator, and that the problematic method is now asList() instead of toList(). So this is a different story.
File > invalidate caches/restartcould help the IDE? You can also try to run./gradlew buildto test this on the command line.