Android resources converted to TypedValue warning string

Ok, I'm looking right here for something.

Every time I am in my application and I change actions, logcat reports a series of warnings:

02-04 14:42:36.524: WARN/Resources(1832): Converting to string: TypedValue{t=0x12/d=0x0 a=2 r=0x7f08002b} 02-04 14:42:36.524: WARN/Resources(1832): Converting to string: TypedValue{t=0x12/d=0x0 a=2 r=0x7f08002c} 02-04 14:42:36.524: WARN/Resources(1832): Converting to string: TypedValue{t=0x12/d=0x0 a=2 r=0x7f08002d} 

Other applications do not show such warnings. Is this a preview / compression?

+49
android resources
04 Feb 2018-11-11T00:
source share
6 answers

You are using the bool resource where a string is expected.

You can find which resource is being used incorrectly by opening your generated R.java file and searching for resource identifiers from the logcat message:

 0x7f08002b 0x7f08002c 0x7f08002d 

All three should be from your bool.xml file ("t = 0x12" in the warning message means that the resources are TYPE_INT_BOOLEAN ).

Then find where these resource identifiers are used in your project (perhaps an xml layout, but maybe anywhere) and make sure the types match.

Here is an example TextView that will generate this log message. If in my res / values ​​/bool.xml I have:

 <resources> <bool name="foo_flag">false</bool> </resources> 

I can incorrectly refer to it from the XML layout file:

 <TextView android:id="@+id/foo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@bool/foo_flag"></TextView> 

When I run this application, I will get a warning message, since the text expects a string resource, not a bool (my application looks as expected, although, since the flag is converted to the string "false").

+55
Feb 05 '11 at 1:50
source share

These warnings appeared only when a specific developer option was enabled.

Device Settings> Developer Settings> Disable Enable Enable View Attribute Verification

+60
Nov 20 '14 at 1:04
source share

I found that this warning also appears when specifying a plural string from a widget that requires parameters.

For example:

 <plurals name="song_count"> <item quantity="one">%d song in playlist</item> <item quantity="other">%d songs in playlist</item> </plurals> 

A warning will appear when the activity containing the widget that links to it is inflated:

 <TextView android:id="@+id/tv_total_songs" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@plurals/song_count" /> 

You will undoubtedly replace the line after inflating the views to set the correct parameters, for example:

 playlistSongCount.setText( getResources().getQuantityString( R.plurals.song_count, songCount, songCount)); 

The obvious solution here is to remove the android:text attribute from the layout, as it has no purpose.

+3
Oct 19 '12 at 9:26
source share

Check if you have: -

 <TextView android:text="@+id/labelText"/> 

in the resource file.

+2
Jul 15 '14 at 9:32
source share

The problem in android:text="@+id/fooText

Try changing your .xml:

 <TextView android:id="@+id/foo" android:text="@+id/fooText"/> 

For this:

 <TextView android:id="@+id/foo" android:text=""/> 
0
Aug 11 '14 at
source share

In my case, the problem was in the ListPreference default ListPreference . Even if you enter it as a String (for example, "10" ), it will be interpreted as an int and then converted to a String and therefore complain.

For example, this will give a warning:

 <ListPreference android:defaultValue="10" ... /> 

but it will not be

 <ListPreference android:defaultValue="@string/ten" ... /> 

and define @string/ten in strings.xml as:

 <string name="ten" translatable="false">10</string> 

Dumb, but it eliminates the warning.

0
Apr 24 '19 at 20:04 on
source share



All Articles