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 trial

Android Build an Interactive Story App (Retired) Finishing the User Interface Wrapping Up

Errors when trying to launch the app

Hi, I've followed along Ben, and I have got the same code, I've checked it, but when I'm trying to launch the app on the emulator, I get these errors:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.tgabor.interactivestory/com.example.tgabor.interactivestory.ui.MainActivity}: android.view.InflateException: Binary XML file line #16: Failed to resolve attribute at index 6: TypedValue{t=0x1d/d=0xff3f51b5 a=2 r=0x7f0b0013}
                                                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
                                                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                                                   at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                                                   at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                   at android.os.Looper.loop(Looper.java:148)
                                                                                   at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                                   at java.lang.reflect.Method.invoke(Native Method)
                                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                                                Caused by: android.view.InflateException: Binary XML file line #16: Failed to resolve attribute at index 6: TypedValue{t=0x1d/d=0xff3f51b5 a=2 r=0x7f0b0013}
                                                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
                                                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
                                                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
                                                                                   at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:256)
                                                                                   at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
                                                                                   at com.example.tgabor.interactivestory.ui.MainActivity.onCreate(MainActivity.java:20)
                                                                                   at android.app.Activity.performCreate(Activity.java:6237)
                                                                                   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
                                                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
                                                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                                                                   at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                                                                   at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                   at android.os.Looper.loop(Looper.java:148) 
                                                                                   at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                                   at java.lang.reflect.Method.invoke(Native Method) 
                                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
                                                                                Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 6: TypedValue{t=0x1d/d=0xff3f51b5 a=2 r=0x7f0b0013}
                                                                                   at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:705)
                                                                                   at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:6890)
                                                                                   at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:7071)
                                                                                   at android.widget.LinearLayout$LayoutParams.<init>(LinearLayout.java:1911)
                                                                                   at android.support.design.widget.AppBarLayout$LayoutParams.<init>(AppBarLayout.java:554)
                                                                                   at android.support.design.widget.AppBarLayout.generateLayoutParams(AppBarLayout.java:284)
                                                                                   at android.support.design.widget.AppBarLayout.generateLayoutParams(AppBarLayout.java:97)
                                                                                   at android.view.LayoutInflater.rInflate(LayoutInflater.java:837)
                                                                                   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
                                                                                   at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
                                                                                   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
                                                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
                                                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
                                                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
                                                                                   at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:256) 
                                                                                   at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109) 
                                                                                   at com.example.tgabor.interactivestory.ui.MainActivity.onCreate(MainActivity.java:20) 
                                                                                   at android.app.Activity.performCreate(Activity.java:6237) 
                                                                                   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
                                                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
                                                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                                                                   at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                                                                   at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                   at android.os.Looper.loop(Looper.java:148) 
                                                                                   at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                                   at java.lang.reflect.Method.invoke(Native Method) 
                                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

Could someone help me please?

Hi Gabor,

maybe something wrong with this:

Binary XML file line #16: Failed to resolve attribute at index 6

Look at the line 16 in the XML ...

Let us know what is there wrong

Here's the code of activity_main:

<?xml version="1.0" encoding="utf-8"?>

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:context=".ui.MainActivity">

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay"/>

</android.support.design.widget.AppBarLayout>

<include layout="@layout/content_main"/>

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_margin="@dimen/fab_margin"
    android:src="@android:drawable/ic_dialog_email"/>

</android.support.design.widget.CoordinatorLayout>

And here's the code of content_main:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:context=".ui.MainActivity" tools:showIn="@layout/activity_main" android:background="@android:color/white">

<ImageView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/titleImageView"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:src="@drawable/main_title"
    android:scaleType="fitXY"
    android:adjustViewBounds="true"
    android:contentDescription="Signals from Mars"/>

<Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="START YOUR ADVENTURE"
    android:id="@+id/startButton"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:background="@android:color/white"
    android:textColor="#ff3a8aec"/>

<EditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:inputType="textPersonName"
    android:ems="10"
    android:id="@+id/nameEditText"
    android:hint="Enter your name to begin"
    android:maxLength="30"
    android:layout_above="@+id/startButton"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:background="@android:color/white"/>

</RelativeLayout>

3 Answers

seems the first element under the first line is missing

Look under --> <?xml version="1.0" encoding="utf-8"?> there suppose to be a layout tag.

agreed

What should stand there?

depends what layout you are using either

"less than symbol" RelativeLayout

or

"less that symbol" LinearLayout

look at your closing tag at the end of the xml file or copy paste the whole file here so we can see.

I checked it, and it is in my code but somehow I didn't include it in my code

we cant guess how your code is going you need to supply more information. kindly paste the full code of the affected layout.