How to determine where the code is incorrect if I get a Convert to string: TypedValue warning?

Here is an excerpt from LogCat:

04-04 19:51:51.270: INFO/ActivityManager(57): Starting activity: Intent { cmp=com.example.app/.Preferences } 04-04 19:51:51.710: WARN/Resources(1081): Converting to string: TypedValue{t=0x10/d=0x0 a=-1} 04-04 19:51:51.740: WARN/Resources(1081): Converting to string: TypedValue{t=0x10/d=0x0 a=-1} 04-04 19:51:51.761: WARN/Resources(1081): Converting to string: TypedValue{t=0x10/d=0x79e a=-1} 04-04 19:51:51.800: WARN/Resources(1081): Converting to string: TypedValue{t=0x10/d=0x5a0 a=-1} 04-04 19:51:51.810: WARN/Resources(1081): Converting to string: TypedValue{t=0x10/d=0x5 a=-1} 04-04 19:51:51.830: WARN/Resources(1081): Converting to string: TypedValue{t=0x10/d=0xa a=-1} 04-04 19:51:51.840: WARN/Resources(1081): Converting to string: TypedValue{t=0x10/d=0xa a=-1} 04-04 19:51:51.860: WARN/Resources(1081): Converting to string: TypedValue{t=0x10/d=0x1e a=-1} 04-04 19:51:51.870: WARN/Resources(1081): Converting to string: TypedValue{t=0x10/d=0x1e a=-1} 04-04 19:51:53.450: INFO/ActivityManager(57): Displayed activity com.example.app/.Preferences: 2061 ms (total 2061 ms) 
+5
android resources android-logcat
Apr 05 2018-11-11T00:
source share
3 answers

TypedValue that you get from logcat can be interpreted as follows:

  • t ==> type ( 0x10 = TYPE_INT_DEC )
  • d ==> actual data (to be indexed as indicated by t )
  • a ==> Additional information about where the cost was received from; just a set for strings.
  • r ==> final resource identifier (not set if you passed a literal value)

So, I think you need to look for the integers that you put where the lines were expecting.

+12
Apr 05 2018-11-11T00:
source share

This problem bothered me; I found that logcat warnings come from android:defaultValue , not the <item> entries in the array. You can resolve these messages by creating string entries in an XML file (I use /xml/constants.xml, but the naming convention is up to you and does not matter) as follows:

  <resources> <string name="someValueA">12345</string> <string name="someValueB">0</string> <string name="someValueC">6789</string> </resources> 

Although these values ​​are integers, since you declare them as strings, Android treats them as strings, so the logcat warning is not generated.

In your code, specify the link @string/someValueA or R.string.someValueA (or B, or C, etc.) depending on the situation wherever you place these values. In the case of ListPreference in the xml file, you should use something like this:

  <ListPreference android:defaultValue="@string/someValueA" android:dialogTitle="Some dialog title" android:entries="@array/someNamesA" android:entryValues="@array/someValuesA" android:key="some_preference" android:summary="Your summary text" android:title="Some Title" /> 

Once you find the entries that cause the problem, don't be scared to solve it. The conversion of the "d" values ​​in logcat messages from hexadecimal to decimal should be pointed in the right direction. For example, 0x5a0 - 1440, so you must determine where you used the value 1440 in your code.

+7
Feb 20 '14 at 23:54
source share

I had this problem when I turned on the "Enable view attribute verification" option inside:

Settings > Developer Options > Debugging

As soon as I turned off this setting, the device stopped sending logcat with these warnings.

+1
Feb 09 '16 at 8:13
source share



All Articles