1

I'm having trouble with my app.. When I press a button that starts a new activity (The menu of the app) I'm having a java.lang.RuntimeException: Error inflating class Button

Does anybody can explain me what is this exception?

This is the XML of the menu activity

<android.support.v7.widget.Toolbar
    android:id="@+id/Toolbar"
    android:layout_width="match_parent"
    android:layout_height="91dp"
    android:background="@color/colorPrimary"
    android:elevation="4dp"
    android:minHeight="?attr/actionBarSize"
    android:theme="?attr/actionBarTheme"     tools:targetApi="lollipop" />

<ScrollView
    android:id="@+id/scrollview"
    android:layout_width="441dp"
    android:layout_height="726dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent">


    <LinearLayout
        android:id="@+id/linearlayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/background_light"
        android:orientation="vertical">


        <Button
            android:id="@+id/saludos"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="100dp"
            android:layout_marginBottom="100dp"
            android:background="@drawable/saludos"
            android:paddingTop="50dp"
            android:paddingBottom="50dp"
            android:text="@string/greetings_n_saludos"
            android:textColor="@android:color/background_dark"
            tools:targetApi="lollipop" />

        <Button
            android:id="@+id/presentaciones"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="100dp"
            android:layout_marginBottom="100dp"
            android:background="@drawable/presentaciones"
            android:text="@string/presentaciones"
            android:textColor="@android:color/background_light" />

        <Button
            android:id="@+id/despedidas"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="100dp"
            android:layout_marginBottom="100dp"
            android:background="@drawable/despedidas"
            android:text="@string/despedidas"
            android:textColor="@android:color/white" />

        <Button
            android:id="@+id/school"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="100dp"
            android:layout_marginBottom="50dp"
            android:background="@drawable/school"
            android:text="@string/school_colegio"
            android:textColor="@android:color/background_light" />

        <Button
            android:id="@+id/numbers"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="100dp"
            android:layout_marginBottom="100dp"
            android:layout_weight="1"
            android:background="@drawable/numbers"
            android:text="@string/numbers_n_meros"
            android:textColor="@android:color/background_light" />

        <Button
            android:id="@+id/colors"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="100dp"
            android:layout_marginBottom="100dp"
            android:background="@drawable/colors"
            android:text="@string/colors_colores"
            android:textColor="@android:color/background_light" />

        <Button
            android:id="@+id/family"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="100dp"
            android:layout_marginBottom="100dp"
            android:background="@drawable/family"
            android:text="@string/family_familia"
            android:textColor="@android:color/black" />

        <Button
            android:id="@+id/food"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="100dp"
            android:layout_marginBottom="100dp"
            android:background="@drawable/food"
            android:text="@string/food_comida"
            android:textColor="@android:color/background_light" />

        <Button
            android:id="@+id/verbtobe"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="100dp"
            android:layout_marginBottom="50dp"
            android:background="@drawable/verbtobe"
            android:text="@string/verb_to_be"
            android:textColor="@android:color/background_light" />

        <Button
            android:id="@+id/havegot"
            android:layout_width="143dp"
            android:layout_height="121dp"
            android:layout_gravity="center"
            android:layout_marginTop="100dp"
            android:layout_marginBottom="100dp"
            android:background="@drawable/havegot"
            android:text="@string/to_have"
            android:textColor="@android:color/background_light" />

        <Button
            android:id="@+id/verbs"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="100dp"
            android:layout_marginBottom="100dp"
            android:background="@drawable/verbs"
            android:text="@string/verbs_n_verbos"
            android:textColor="@android:color/background_light" />


        <Button
            android:id="@+id/presentsimple"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="100dp"
            android:layout_marginBottom="100dp"
            android:background="@drawable/presentsimple"
            android:text="@string/present_simple"
            android:textColor="@android:color/background_dark"
            tools:text="@string/present_simple" />

        <Button
            android:id="@+id/presentcontinuous"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="100dp"
            android:layout_marginBottom="50dp"
            android:background="@drawable/presentcontinuous"
            android:text="@string/present_continuous"
            android:textColor="@android:color/background_light" />

        <Button
            android:id="@+id/pastsimple"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="100dp"
            android:layout_marginBottom="100dp"
            android:background="@drawable/pastsimple"
            android:text="@string/past_simple"
            android:textColor="@android:color/background_dark" />

        <Button
            android:id="@+id/pastcontinuous"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="100dp"
            android:layout_marginBottom="100dp"
            android:background="@drawable/pastcontinuous"
            android:text="@string/past_continuous"
            android:textColor="@android:color/background_light" />

        <Button
            android:id="@+id/presentperfect"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="100dp"
            android:layout_marginBottom="100dp"
            android:background="@drawable/presentperfect"
            android:text="@string/past_continuous"
            android:textColor="@android:color/background_dark" />

        <Button
            android:id="@+id/presentperfectcontinuous"
            android:layout_width="wrap_content"
            android:layout_height="161dp"
            android:layout_gravity="center"
            android:layout_marginTop="100dp"
            android:layout_marginBottom="100dp"
            android:background="@drawable/presentcontinuous"
            android:text="@string/past_continuous"
            android:textColor="@android:color/background_dark" />

        <Button
            android:id="@+id/pastperfect"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="100dp"
            android:layout_marginBottom="50dp"
            android:background="@drawable/presentcontinuous"
            android:text="@string/past_continuous"
            android:textColor="@android:color/background_dark" />

        <Button
            android:id="@+id/pastperfectcontinuous"
            android:layout_width="140dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="100dp"
            android:layout_marginBottom="100dp"
            android:background="@drawable/pastperfectcontinuous"
            android:text="@string/past_continuous"
            android:textColor="@android:color/background_dark" />

        <Button
            android:id="@+id/thereisthereare"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="100dp"
            android:layout_marginBottom="100dp"
            android:background="@drawable/thereisthereare"
            android:text="@string/there_is_there_are"
            android:textColor="@android:color/background_light" />

        <Button
            android:id="@+id/nouns"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="100dp"
            android:layout_marginBottom="100dp"
            android:background="@drawable/nouns"
            android:text="@string/nouns_sustantivos"
            android:textColor="@android:color/background_light"
            tools:text="nouns sustantivos" />

        <Button
            android:id="@+id/adverbs"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="100dp"
            android:layout_marginBottom="100dp"
            android:background="@drawable/adverbs"
            android:text="@string/adverbs_los_adverbios"
            android:textColor="@android:color/background_light"
            tools:text="@string/adverbs_los_adverbios" />

        <Button
            android:id="@+id/adjetivos"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="100dp"
            android:layout_marginBottom="100dp"
            android:background="@drawable/adjectives"
            android:text="@string/adjectives_adjetivos"
            android:textColor="@android:color/black"
            tools:text="@string/adjectives_adjetivos" />

        <Button
            android:id="@+id/holidays"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="100dp"
            android:layout_marginBottom="100dp"
            android:background="@drawable/holidays"
            android:text="@string/holidays_vacaciones"
            android:textColor="@drawable/holidays"
            tools:text="@string/holidays_vacaciones" />

        <Button
            android:id="@+id/shopping"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="100dp"
            android:layout_marginBottom="100dp"
            android:background="@drawable/shopping"
            android:text="@string/we_go_shopping_vamos_de_compras"
            android:textColor="@android:color/background_light"
            tools:text="we go shopping!" />

        <Button
            android:id="@+id/quiz"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="50dp"
            android:layout_marginBottom="50dp"
            android:background="@android:color/background_light"
            android:text="@string/quiz"
            android:textColor="@android:color/background_dark"
            tools:text="nouns sustantivos" />

        <Button
            android:id="@+id/people"
            android:layout_width="143dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="100dp"
            android:layout_marginBottom="50dp"
            android:background="@drawable/describing"
                android:text="@string/describing_people_describiendo_gente"
            android:textColor="@android:color/background_dark"
            tools:text="Describing People - Describiendo Gente" />

        <Button
            android:id="@+id/works"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="100dp"
            android:layout_marginBottom="100dp"
            android:background="@drawable/works"
            android:text="@string/works_n_trabajos"
            android:textColor="@android:color/background_light" />

    </LinearLayout>
</ScrollView>

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

And this is the Logcat

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.flixarts.ar.englishnow, PID: 10925
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.flixarts.ar.englishnow/com.flixarts.ar.englishnow.menuscreen}: android.view.InflateException: Binary XML file line #298: Binary XML file line #298: Error inflating class Button
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6669)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
 Caused by: android.view.InflateException: Binary XML file line #298: Binary XML file line #298: Error inflating class Button
 Caused by: android.view.InflateException: Binary XML file line #298: Error inflating class Button
 Caused by: android.content.res.Resources$NotFoundException: Can't find ColorStateList from drawable resource ID #0x7f070075
    at android.content.res.ResourcesImpl.loadColorStateList(ResourcesImpl.java:1042)
    at android.content.res.Resources.loadColorStateList(Resources.java:1041)
    at android.content.res.TypedArray.getColorStateList(TypedArray.java:549)
    at android.widget.TextView.readTextAppearance(TextView.java:3542)
    at android.widget.TextView.<init>(TextView.java:959)
    at android.widget.Button.<init>(Button.java:166)
    at android.widget.Button.<init>(Button.java:141)
    at android.support.v7.widget.AppCompatButton.<init>(AppCompatButton.java:70)
    at android.support.v7.widget.AppCompatButton.<init>(AppCompatButton.java:66)
    at android.support.v7.app.AppCompatViewInflater.createButton(AppCompatViewInflater.java:186)
    at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:109)
    at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1035)
    at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1092)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:772)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
    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.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
    at com.flixarts.ar.englishnow.menuscreen.onCreate(menuscreen.java:45)
    at android.app.Activity.performCreate(Activity.java:7136)
    at android.app.Activity.performCreate(Activity.java:7127)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
E/AndroidRuntime:     at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6669)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.

I don't know what's happening, I've written the code as neatly as i could and that worked but now I have this exception

Mauro Stancato
  • 537
  • 1
  • 9
  • 19
  • put your class LaunchActivityItem.java pls – Dev_Abraham Jun 03 '19 at 05:27
  • I have added to the post thanks – Mauro Stancato Jun 03 '19 at 05:29
  • gotomemenuscreen id is not a id for a view in your xml layout – Raghunandan Jun 03 '19 at 05:34
  • raghunandan gotomenuscreen is in the previous activity... when I press the button on the previous activity with id gotomenuscreen the app crashes – Mauro Stancato Jun 03 '19 at 05:36
  • you are not having any button with id gotomenuscreen as @Raghunandan pointed – Jeeva Jun 03 '19 at 05:36
  • It seems issue is at line number 298 in xml file. 'Caused by: android.view.InflateException: Binary XML file line #298: Binary XML file line #298: Error inflating class Button Caused by: android.view.InflateException: Binary XML file line #298: Error inflating class Button Caused by: android.content.res.Resources$NotFoundException: Can't find ColorStateList from drawable resource ID #0x7f070075' – Rajiv Ranjan Jun 03 '19 at 05:39
  • It seems some of the color code or resource you are using is not available ... so check at line number 298 in your xml layout file. – Rajiv Ranjan Jun 03 '19 at 05:41
  • Check the resources that are set to android:textColor="" – Dinesh Jun 03 '19 at 05:44
  • Possible duplicate of [Android resource not found exception?](https://stackoverflow.com/questions/7727808/android-resource-not-found-exception) – Sandeep Parish Jun 03 '19 at 06:02

2 Answers2

1

Caused by: android.content.res.Resources$NotFoundException: Can't find ColorStateList from drawable resource ID.

This states that the run time env is not able to find a specific resource.

Probably it has be @drawable/holidays . Check if this is part of your project.

Dinesh
  • 948
  • 6
  • 11
0

In your XML, you set textColor with a drawable, textColor is expects a color not a drawable :

<Button
     android:id="@+id/holidays"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_gravity="center"
     android:layout_marginTop="100dp"
     android:layout_marginBottom="100dp"
     android:background="@drawable/holidays"
     android:text="@string/holidays_vacaciones"
     android:textColor="@drawable/holidays"
     tools:text="@string/holidays_vacaciones" />
Faruk
  • 5,438
  • 3
  • 30
  • 46