I get this error when I install my release APK on a 5.x
device. The error does not occur when I push the same code from Android Studio, or if I run it on a
In my case the method that the error message said was 'bad', had some unknown faults. Changing from a Kotlin lambda to a regular loop solved my issue.
Before (With Error):
fun validZipCode(zipcode: String): Boolean {
val validRegexes = arrayOf(
"0[0-9]{1}[0-9]{2}",
"1[0-2]{1}[0-9]{2}",
"1[3-4]{1}[0-9]{2}",
"19[0-9]{2}",
"2[0-1]{1}[0-9]{2}"
)
return validRegexes.any { zipcode.matches(it.toRegex()) }
After:
fun validZipCode(zipcode: String): Boolean {
val validRegexes = arrayOf(
"0[0-9]{1}[0-9]{2}",
"1[0-2]{1}[0-9]{2}",
"1[3-4]{1}[0-9]{2}",
"19[0-9]{2}",
"2[0-1]{1}[0-9]{2}"
)
for (regex in validRegexes) {
if (zipcode.matches(regex.toRegex())) {
return true
}
}
return false
}