My project uses a string declaration in strings.xml similar to:
<string name="file_size">File Size (%1$dMB)</string>
And in my code, I'm using
getResources().getString(R.string.file_size, getFileSize());
Where getFileSize() returns a long. Lint give me this error:
"Wrong argument type for formatting argument '#1' in file_size: conversion is 'd', received long (argument #2 in method call)"
What's going on here? The Android documentation says that:
Looks like a bug in the lint rules. See the source for StringFormatDetector
:
// Numeric: integer and floats in various formats
case 'x':
case 'X':
case 'd':
case 'o':
case 'e':
case 'E':
case 'f':
case 'g':
case 'G':
case 'a':
case 'A':
valid = type == Integer.TYPE
|| type == Float.TYPE;
break;
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