0

what should i add instead of this button code?

Mainactivity

  package com.example.sharma.ubernew;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}

Logcat APP is not starting .stopped.

07-31 19:26:52.919 11371-11371/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.sharma.ubernew, PID: 11371
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sharma.ubernew/com.example.sharma.ubernew.MainActivity}: android.view.InflateException: Binary XML file line #69: Error inflating class Button
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
    at android.app.ActivityThread.access$800(ActivityThread.java:135)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5021)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:827)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:643)
    at dalvik.system.NativeStart.main(Native Method)
 Caused by: android.view.InflateException: Binary XML file line #69: Error inflating class Button
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
    at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
    at com.example.sharma.ubernew.MainActivity.onCreate(MainActivity.java:11)
    at android.app.Activity.performCreate(Activity.java:5397)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
    at android.app.ActivityThread.access$800(ActivityThread.java:135) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:136) 
    at android.app.ActivityThread.main(ActivityThread.java:5021) 
    at java.lang.reflect.Method.invokeNative(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:515) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:827) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:643) 
    at dalvik.system.NativeStart.main(Native Method) 
 Caused by: android.content.res.Resources$NotFoundException: File res/drawable/btn_register_background.xml from drawable resource ID #0x7f07005c
    at android.content.res.Resources.loadDrawable(Resources.java:2131)
    at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
    at android.view.View.<init>(View.java:3694)
    at android.widget.TextView.<init>(TextView.java:629)
    at android.widget.Button.<init>(Button.java:107)
    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:684)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
    at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) 
    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
    at com.example.sharma.ubernew.MainActivity.onCreate(MainActivity.java:11) 
    at android.app.Activity.performCreate(Activity.java:5397) 
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
    at android.app.ActivityThread.access$800(ActivityThread.java:135) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:136) 
    at android.app.ActivityThread.main(ActivityThread.java:5021) 
    at java.lang.reflect.Method.invokeNative(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:515) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:827) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:643) 
    at dalvik.system.NativeStart.main(Native Method) 
 Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #2: invalid drawable tag ripple
    at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:933)
    at android.graphics.drawable.Drawable.createFromXml(Drawable.java:877)
    at android.content.res.Resources.loadDrawable(Resources.java:2127)
    at android.content.res.TypedArray.getDrawable(TypedArray.java:602) 
    at android.view.View.<init>(View.java:3694) 
    at android.widget.TextView.<init>(TextView.java:629) 
    at android.widget.Button.<init>(Button.java:107) 
    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:684) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
    at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) 
    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
    at com.example.sharma.ubernew.MainActivity.onCreate(MainActivity.java:11) 
    at android.app.Activity.performCreate(Activity.java:5397) 
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
    at android.app.ActivityThread.access$800(ActivityThread.java:135) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:136) 
    at android.app.ActivityThread.main(ActivityThread.java:5021) 
    at java.lang.reflect.Method.invokeNative(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:515) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:827) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:643) 
    at dalvik.system.NativeStart.main(Native Method) 

activity_main.xml

    <?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"
    android:background="@drawable/background"
    tools:context=".MainActivity">

<LinearLayout
    android:orientation="vertical"
    android:layout_marginTop="30dp"
    android:layout_centerHorizontal="true"
    android:gravity="center_horizontal"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">


    <TextView
        android:text="U B E R"
        android:textSize="36sp"
        android:textAlignment="center"
        android:textColor="@android:color/white"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <TextView
        android:text="PARTNER"
        android:layout_marginTop="20dp"
        android:textSize="16sp"
        android:textAlignment="center"
        android:textColor="@android:color/white"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</LinearLayout>

    <TextView
        android:id="@+id/txt_rider_app"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="20dp"
        android:layout_marginTop="20dp"
        android:text="LOOKING FOR THE RIDER APP"
        android:textSize="12sp"
        android:textAlignment="center"
        android:layout_width="wrap_content"
        android:textColor="@android:color/white"
        android:layout_height="wrap_content"
        />

<LinearLayout
    android:weightSum="2"
    android:layout_above="@id/txt_rider_app"
    android:layout_margin="16dp"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <Button
        android:id="@+id/btnSignIn"
        android:background="@color/btnSignIn"
        android:textColor="@android:color/white"
        android:text="SIGN IN"
        android:layout_marginRight="6dp"
        android:layout_weight="1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
      />
    <Button
        android:id="@+id/btnRegister"
        android:background="@drawable/btn_register_background"
        android:textColor="@color/btnRegister"
        android:text="REGISTER"
        android:layout_marginLeft="6dp"
        android:layout_weight="1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
    />
</LinearLayout>
</RelativeLayout>

the error is in drawable sign in xml file btn_sign_in_background

 <?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:color="@color/rippleEffectColor"
    tools:targetApi="lollipop">
    <item>
        <shape android:shape="rectangle">
            <solid android:color="@color/btnSignIn"/>
            <stroke android:color="@color/btnSignIn" android:width="2dp">
            </stroke>
            <corners android:radius="2dp"/>

        </shape>
    </item>
</ripple>

btn_register_background

    <?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:color="@color/rippleEffectColor"
    tools:targetApi="lollipop">
    <item>
        <shape android:shape="rectangle">
            <solid android:color="@android:color/white"/>
            <stroke android:color="@android:color/white" android:width="2dp">
            </stroke>
            <corners android:radius="2dp"/>
        </shape>
    </item>
</ripple>
0

2 Answers 2

2

I got this same error while running my application. In my case actually problem is that custom_button.xml drawable file present in drawable-v21 folder not in drawable folder, which causes the error, I removed it by copying it into on drawable folder I think in your case btn_register_background.xml file present In something folder like drawable-v21 or drawable-v24 or anything like that, try copy btn_register_background.xml into drawable folder.

Sign up to request clarification or add additional context in comments.

Comments

0

You are using @color/btnSignIn. Change this to @drawable/btn_sign_in_background in android:background property as done in:-

<Button
    android:id="@+id/btnSignIn"
    android:background="@drawable/btn_sign_in_background"
    android:textColor="@android:color/white"
    android:text="SIGN IN"
    android:layout_marginRight="6dp"
    android:layout_weight="1"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
/>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.