Issue
At random points while I'm using my Android application, 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 determined that it is trying to interpret nulls (0x0) as booleans (0x12), which makes no sense, as I'm never dealing with either nulls or booleans.
The resource IDs from the logs (r=0x?) point to views/view attributes within one of two layouts, which I'll include below.
The only places in my code where I reference those resource IDs are a) the CursorAdapter that uses the first layout, and b) a class that uses the second layout and I will include that code below as well.
I'm not sure if this is something to worry about. I know correlation does not imply causation, but when LogCat is flooded with those logs, scrolling through my app is noticeably janky.
Any help with figuring out what is going on would 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)));
}
}
Other 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'll include what each resource ID references in my layout file
0x7f0b00d8: event_type
0xffe51c23: primary
(my app's primary color)
0x7f0b008a: event_name
0x7f0b00d6: event_dates
0x7f0b00d7: event_location
Also, note that this is running on the 5.0 Preview. However, I still saw these logs back when I was on 4.4.4.
EDIT #2
After searching through the Android source code, I've discovered that the only place that "Converting to String" exists is in the class android.content.res.TypedArray
.
However, I never even instantiate, import, or in any way use that class in my project! This just gets weirder and weirder.
EDIT #3
Per the request of a commenter, I have uploaded my styles.xml
and colors.xml
to a gist, which can be found here.
Solution
I filed a bug report with the Android team, as I still couldn't explain or fix this issue. The bug report is here. A commenter suggested that I uncheck "Enable view attribute inspection" in the Developer Options. Lo and behold, this problem is now fixed! I don't remember ever checking that, which is weird, but at least I now know what causes this problem.
Answered By - Nathan Walters
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.