I have a string res and kotlin data class below:
<string name="amount_format">¥%1$.2f</string>
data class TagAndTotal(
@ColumnInfo(name = "tag_name") var tagName: String,
@ColumnInfo(name = "total") var total: Float)
I got error below when I run ./gradlew lint
after I upgrade to AGP 3.1.0.
Error: Wrong argument type for formatting argument '#1' in
amount_format: conversion is 'f', received <ErrorType> (argument #2 in
method call) [StringFormatMatches]
applicationContext.getString(R.string.amount_format, it.total))
But it's no error in AGP 3.0.1.
I got the same problem. Declare an explicit local variable with type solve my problem.
In your case, could you try:
val total : Double = it.total
applicationContext.getString(R.string.amount_format, total)
I think this is a bug in AGP
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With