-1

Hi my app crashes whenever i run it, i checked Logcat and it gives this string of error

my code and the structure of my app is below , i have been looking for answer and hope someone help me.

thanks in advance

       Caused by: android.view.InflateException: Binary XML file line #51: 
             Error inflating class Button.

        Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f070063 a=-1 r=0x7f070063}

here is my XML

    <?xml version="1.0" encoding="utf-8"?>  android.support.constraint.ConstraintLayout 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"
    tools:context=".MainActivity">





    <!--tools:layout_editor_absoluteX="16dp"-->
    <!--tools:layout_editor_absoluteY="81dp"-->


    <android.support.constraint.ConstraintLayout
        android:layout_width="135dp"
        android:layout_height="203dp"
        android:layout_marginLeft="4dp"
        android:layout_marginStart="4dp"
        android:layout_marginTop="60dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <TextView
            android:id="@+id/textView_login"
            style="@style/Longin"
            android:layout_width="69dp"
            android:layout_height="30dp"
            android:layout_marginLeft="4dp"
            android:layout_marginStart="4dp"
            android:text="@string/app_loging"
            android:translationZ="3dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_bias="0.15" />
    </android.support.constraint.ConstraintLayout>


    <android.support.constraint.ConstraintLayout
        android:layout_width="172dp"
        android:layout_height="431dp"
        android:layout_marginTop="64dp"

        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent">


        <Button
            android:id="@+id/backedbackground"
            style="@style/first"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginLeft="16dp"
            android:layout_marginStart="16dp"
            android:background="@drawable/first"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />


        <TextView
            android:id="@+id/textView_signup"
            style="@style/Longin"
            android:layout_width="69dp"
            android:layout_height="30dp"
            android:layout_marginEnd="8dp"
            android:layout_marginLeft="8dp"
            android:layout_marginRight="8dp"
            android:layout_marginStart="8dp"
            android:layout_marginTop="24dp"
            android:text="@string/app_singup"
            android:textColor="@color/colorwhite"
            android:translationZ="3dp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.908"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

    </android.support.constraint.ConstraintLayout>


    <android.support.constraint.ConstraintLayout
        android:layout_width="312dp"
        android:layout_height="319dp"
        android:layout_marginTop="124dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">


        <Button
            android:id="@+id/button2"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/signupfrontbackground"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="1.0"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_bias="0.0"

            />

        <EditText
            android:id="@+id/editText1"
            android:layout_width="wrap_content"
            android:layout_height="62dp"
            android:layout_marginTop="24dp"
            android:drawableRight="@drawable/ic_user_male_black_shape"
            android:ems="10"
            android:hint="User name"
            android:inputType="textPersonName"
            android:translationZ="2dp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.505"
            app:layout_constraintStart_toStartOf="parent"

            app:layout_constraintTop_toTopOf="parent" />

        <EditText
            android:id="@+id/editText2"
            android:layout_width="wrap_content"
            android:layout_height="56dp"
            android:drawableRight="@drawable/ic_envelope"
            android:ems="10"
            android:hint="@string/app_Email"
            android:inputType="textEmailAddress"
            android:translationZ="2dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.505"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_bias="0.329" />

        <EditText
            android:id="@+id/editText3"
            android:layout_width="wrap_content"
            android:layout_height="59dp"
            android:layout_marginTop="140dp"
            android:drawableRight="@drawable/ic_key"
            android:ems="10"
            android:hint="@string/app_Password"
            android:inputType="textPassword"
            android:translationZ="2dp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.505"

            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="@+id/button2" />


        <EditText
            android:id="@+id/editText4"
            android:layout_width="wrap_content"
            android:layout_height="60dp"
            android:layout_marginTop="200dp"
            android:drawableRight="@drawable/ic_key"
            android:ems="10"
            android:hint="@string/app_Confirm_password"
            android:inputType="textPassword"
            android:translationZ="2dp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.505"

            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="@+id/button2"

            />


    </android.support.constraint.ConstraintLayout>

    <Button
        android:id="@+id/button"
        android:layout_width="128dp"
        android:layout_height="38dp"
        android:layout_marginBottom="44dp"
        android:layout_marginEnd="116dp"
        android:layout_marginRight="116dp"
        android:background="@drawable/signupbutton"
        android:text="@string/app_singup"
        android:textColor="@color/colorwhite"
        android:translationZ="2dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"

        />


</android.support.constraint.ConstraintLayout>

my style

   <resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>



        <dimen name="topRightRadius">65dp</dimen>
        <dimen name="textSize">20dp</dimen>


    <style name="first">

          <item name="android:topRightRadius">@dimen/topRightRadius</item>
          <!--<item name="android:radius">65dp</item>-->
          <item name="android:background">@color/colorAccent</item>



    </style>

    <style name="Longin">

        <item name="android:textColor">@color/colorwhiteblack</item>
        <item name="android:textSize">20dp</item>

    </style>


</resources>

Manifest

         <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.ali.myapplication">



    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity"
            android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"
            >

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

my string

       <resources>
    <string name="app_name">My Doctor</string>
    <string name="app_loging">Login</string>
    <string name="app_singup">Sign up</string>
    <string name="app_Email">Email</string>
    <string name="app_Password">Password</string>
    <string name="app_Confirm_password">Confirm password</string>
</resources>

my Color

    <?xml version="1.0" encoding="utf-8"?>    <resources>
    <color name="colorPrimary">#3F51B5</color>
    <color name="colorPrimaryDark">#303F9F</color>
    <color name="colorAccent">#FF4081</color>
    <color name="colorwhite">#ffffff</color>
    <color name="colortoowhite">#efe9e9</color>
    <color name="colorblack">#0d0c0c</color>
    <color name="colorwhiteblack">#c1baba</color>
    <color name="colorharaqua">#15c5e4</color>
    <color name="coloraqua">#ed1fd3e7</color>
</resources>

Structure of my app Structure of my app is below Structure of my app is below

structure

first

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item   android:state_enabled="true">

        <shape android:shape="rectangle">
            <!--<corners android:topRightRadius="45dp"/>-->
               <corners android:topLeftRadius="45dp"
                   android:topRightRadius="0.1dp"
                   android:bottomLeftRadius="45dp"
                   android:bottomRightRadius="0.1dp"/>


            <gradient   android:gradientRadius="45dp"
                android:angle="-90" android:startColor="#5a92f0"
                android:endColor="@color/colorAccent" />

        </shape>
    </item>


</selector>

signupfrontbackground

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape ="rectangle">



      <corners android:radius="20dp"/>

       <solid android:color="@color/colorwhite"/>

     <stroke
         android:color="@color/colortoowhite"
         android:width="1dp"

         />

       <!--<padding-->
           <!--android:right="10dp"-->
           <!--android:bottom="10dp"-->
           <!--android:left="10dp"-->
           <!--android:top="10dp"/>-->

</shape>

signupbutton

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">





    <gradient
        android:startColor="@color/colorharaqua"
        android:endColor="@color/coloraqua"
        android:angle="360"
        />

    <corners android:topLeftRadius="105dp"
             android:bottomLeftRadius="105dp"
             android:topRightRadius="95dp"
             android:bottomRightRadius="95dp"

        />

</shape>

2 Answers2

1

It is complaining about your background pointer to a non-drawable id.

 android:background="@drawable/signupbutton"

Show your drawable by this name that is in the drawable directory.

Also, just a side note,

Your style "first" doesn't have a parent. You might want to try assigning a button parent to your style. Such as

<style name="first" parent="Widget.AppCompat.Button.Colored">
    <item name="colorButtonNormal">@color/Red</item>
    <item name="android:textColor">@color/White</item>
</style>

Just so you are tied to a specific parent of your theme instead of leaving it open, but that's just my preference.

Sam
  • 5,342
  • 1
  • 23
  • 39
  • Thanks man for replying i will look , just i want to know how do you recognize the problem relates to "@drawable/signupbutton" there is not clear point to it in the error , just want to know for further knowledge – jhonfkanadi2 jhonfkanadi2 May 11 '18 at 18:01
  • It gave a line number and referenced a button and said the problem was the used drawable. In your button xml you only have one line where you are pointing to a drawable. so it was process of elimination. – Sam May 11 '18 at 18:26
  • Thansk Sam "Show your drawable by this name that is in the drawable directory."i do not understand what i do to fix the problem ,could you please explain more – jhonfkanadi2 jhonfkanadi2 May 11 '18 at 18:45
  • You have two options. Either delete the background=@drawable line i posted in my answer or go to the drawable folder and make an xml file named signupbutton that you will use for this button's design. If you are not supplying a design drawable, then just delete that line. If you are, then create the drawable or repair your xml if it already exists as that means you have bad xml in your drawable if it exists and still crashes there. – Sam May 11 '18 at 20:04
0

Your drawables look fine, but they are in v24 folder, so if you're launching this on a pre-24 device, they won't be available. I was able to reproduce your crash by setting the same folder structure and using v23 emulator.

Dennis K
  • 1,828
  • 1
  • 16
  • 27