Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAlex Lowe
15,147 PointsApp Crashing
I'm experiencing crashes in a couple instances. First, when the app opens and I see the progress bar for a second and then it crashes. The Exception in the Logcat says:
android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
and points to a line that references my listing_layout.
When I looked it up, the problem seems to stem from large images taking up too much memory. Is there a way to force the images to be a certain resolution?
When I remove "android:foreground="@drawable/highlight_selector"" from my XML, the app will load, but obviously the layout is off.
Here's my code for layout_listing.xml:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:foreground="@drawable/highlight_selector">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/listing_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/image_desc"
android:minHeight="150dp"
android:scaleType="centerCrop"/>
<com.google.android.gms.plus.PlusOneButton
android:id="@+id/listing_plus_one_btn"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignTop="@+id/listing_share_btn"
android:layout_toLeftOf="@+id/listing_share_btn"
android:layout_toStartOf="@+id/listing_share_btn"/>
<ImageButton
android:id="@+id/listing_share_btn"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:contentDescription="@string/share_desc"
android:src="@drawable/ic_social_share"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:padding="4dp">
<TextView
android:id="@+id/listing_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sample Title"
android:textColor="@android:color/black"/>
<TextView
android:id="@+id/listing_shop_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@id/listing_title"
android:text="Sample Shop Name"
android:textColor="@android:color/darker_gray"/>
<TextView
android:id="@+id/listing_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="@id/listing_title"
android:text="$00.00"
android:textColor="@android:color/holo_green_dark"
/>
</RelativeLayout>
</LinearLayout>
</FrameLayout>
And also when I click on an item, and go to an Etsy page, if I hit the back button, the app crashes, and in my logcat:
Caused by: java.lang.ClassCastException: android.os.Parcelable[] cannot be cast to com.alexlowe.recommendations.model.Image[] at com.alexlowe.recommendations.model.Listing$1.createFromParcel(Listing.java:45)
This is the line it's referencing:
listing.Images = (Image[]) source.readParcelableArray(Image.class.getClassLoader());
This only happens with the stock browser, not with chrome.
Does anyone know what might fix these issues?
Timothy Boland
18,237 PointsHi Alex. Did you ever get this problem fixed?
Timothy Boland
18,237 PointsTimothy Boland
18,237 PointsIm experiencing this problem also