https://kotlinlang.org logo
Title
e

Erfan

07/27/2018, 6:29 PM
hi guys, I have a free function like this:
fun addQueryStrings(keyValues: Map<String, String>, baseUrl: String): String {
    var url = baseUrl + "?"
    val firstKey = keyValues.keys.first()

    keyValues.forEach { key, value ->
        if (key != firstKey) { url += "&" }

        url += "$key=$value"
    }

    return url
}
and I've received several crash report with this error:
Fatal Exception: java.lang.NoClassDefFoundError
blah.blah.blah.DataLayer.APICommunicatorKt.addQueryStrings
What is wrong here? Is there anything wrong with using free function here? (note: it does not happen on all devices)
m

Morten

08/03/2018, 7:50 AM
Don’t know if you already got an answer on this one but map.forEach(key, value -> …) is Java 8 so it would fail on older Android versions. Use map.forEach( (key, value) -> …) should do the trick