TypedValue Convert to String

At random points, when I use my Android app, LogCat is flooded with dozens of repetitions of the following 5 lines:

10-26 12:53:30.372 21270-21270 W/Resources﹕ Converting to string: TypedValue{t=0x12/d=0x0 a=2 r=0x7f0b00d8} 10-26 12:53:30.372 21270-21270 W/Resources﹕ Converting to string: TypedValue{t=0x1d/d=0xffe51c23 a=2 r=0x7f090047} 10-26 12:53:30.374 21270-21270 W/Resources﹕ Converting to string: TypedValue{t=0x12/d=0x0 a=2 r=0x7f0b008a} 10-26 12:53:30.375 21270-21270 W/Resources﹕ Converting to string: TypedValue{t=0x12/d=0x0 a=2 r=0x7f0b00d6} 10-26 12:53:30.375 21270-21270 W/Resources﹕ Converting to string: TypedValue{t=0x12/d=0x0 a=2 r=0x7f0b00d7} 

Using the information from the accepted answer to this question , I decided that he was trying to interpret the values ​​null (0x0) as booleans (0x12), which makes no sense, since I never deal with either zeros or booleans.

Log resource identifiers (r = 0x?) Indicate attribute views / representations in one of two layouts, which I will include below.

The only places in my code where I refer to these resource identifiers are: a) a CursorAdapter that uses the first layout, and b) a class that uses the second layout, and I will also include this code below.

I am not sure what to worry about. I know that correlation does not imply causality, but when LogCat is flooded with these logs, scrolling through my application twitches noticeably.

Any help in figuring out what is going on will be appreciated.

Layout File # 1:

 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="72dp" android:padding="16dp"> <TextView android:id="@+id/event_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:ellipsize="end" android:maxLines="1" android:text="Title" android:textSize="16sp" android:textColor="@color/primary_text_color"/> <TextView android:id="@+id/event_dates" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_below="@id/event_name" android:text="Dates" android:textColor="@color/secondary_text_color" android:textSize="14sp" /> <TextView android:id="@+id/event_location" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@id/event_name" android:layout_toLeftOf="@id/event_dates" android:ellipsize="end" android:singleLine="true" android:text="Location" android:textColor="@color/secondary_text_color" android:textSize="14sp" /> </RelativeLayout> 

Layout File # 2:

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/event_type" android:textSize="14sp" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@color/primary" android:paddingLeft="16dp" android:paddingTop="8dp" android:paddingBottom="8dp" android:text="Header" android:textColor="#FFFFFF" /> </LinearLayout> 

CursorAdapter:

 public class EventCursorAdapter extends CursorAdapter { public String getKey(int position) { Cursor c = getCursor(); c.moveToPosition(position); return c.getString(c.getColumnIndex(Database.Events.KEY)); } public EventCursorAdapter(Context context, Cursor c, int flags) { super(context, c, flags); } @Override public View newView(Context context, Cursor cursor, ViewGroup viewGroup) { LayoutInflater inflater = LayoutInflater.from(context); return inflater.inflate(R.layout.list_item_event, viewGroup, false); } @Override public void bindView(View view, Context context, Cursor cursor) { TextView dates = (TextView) view.findViewById(R.id.event_dates); Date startDate = null, endDate = null; Log.d(Constants.LOG_TAG, "Start: " + cursor.getString(cursor.getColumnIndex(Database.Events.START))); try { startDate = new Date(cursor.getLong(cursor.getColumnIndex(Database.Events.START))); endDate = new Date(cursor.getLong(cursor.getColumnIndex(Database.Events.END))); } catch (Exception e) { // Oops. } dates.setText(EventHelper.getDateString(startDate, endDate)); TextView name = (TextView) view.findViewById(R.id.event_name); name.setText(cursor.getString(cursor.getColumnIndex(Database.Events.NAME))); TextView location = (TextView) view.findViewById(R.id.event_location); location.setText(cursor.getString(cursor.getColumnIndex(Database.Events.LOCATION))); } } 

Another class:

 public class EventTypeHeader extends ListHeader { public EventTypeHeader(String title) { super(title); } @Override public View getView(Context c, LayoutInflater inflater, View convertView) { ViewHolder holder; if (convertView == null || !(convertView.getTag() instanceof ViewHolder)) { convertView = inflater.inflate(R.layout.list_item_event_type_header, null); holder = new ViewHolder(); holder.text = (TextView) convertView.findViewById(R.id.event_type); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.text.setText(getText()); return convertView; } private static class ViewHolder { TextView text; } } 

EDIT

I will include what refers to each resource identifier in my layout file

0x7f0b00d8: event_type

0xffe51c23: primary (application primary color)

0x7f0b008a: event_name

0x7f0b00d6: event_dates

0x7f0b00d7: event_location

Also note that this works in 5.0 Preview. However, I still saw these logs when I was in 4.4.4.

EDIT No. 2

After searching the Android source code, I found that the only place where "Convert to String" exists is in the android.content.res.TypedArray class.

However, I do not even create an instance, I do not import or use this class in my project! It just gets weirder and weirder.

EDIT No. 3

At the request of the commentator, I uploaded my styles.xml and colors.xml to the gist, which can be found here .

+22
android android-resources
Oct 26 '14 at 18:15
source share
1 answer

I sent an error report to the Android team, as I still could not explain or fix this problem. Error report here . One of the commentators suggested unchecking “Enable verification of viewing attributes” in “Developer options”. So this problem is now fixed! I don’t remember ever checking this, which is strange, but at least now I know what causes this problem.

+29
Nov 10 '14 at 22:11
source share



All Articles