1

i am a beginner student of android basics course and i was making an score keeper app but when i run it with my mobile phone on android studio it is giving the following log error as well as showing "unfortunately has stopped" on my device.

I am very worried about this situation because i am new to android development and get this problem i will be more thankful to you anyone who will be able to solve this problem because it has stucked in my mind

LogCat

06-02 22:38:55.991 30457-30457/? I/art: Late-enabling -Xcheck:jni
06-02 22:38:56.059 30457-30457/com.example.tasbeeh.tasbeehcounter W/System: ClassLoader referenced unknown path: /data/app/com.example.tasbeeh.tasbeehcounter-1/lib/arm
06-02 22:38:56.107 30457-30457/com.example.tasbeeh.tasbeehcounter W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
06-02 22:38:56.192 30457-30457/com.example.tasbeeh.tasbeehcounter W/ResourceType: Failure getting entry for 0x7f060054 (t=5 e=84) (error -75)
06-02 22:38:56.194 30457-30457/com.example.tasbeeh.tasbeehcounter D/AndroidRuntime: Shutting down VM
06-02 22:38:56.197 30457-30457/com.example.tasbeeh.tasbeehcounter E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.tasbeeh.tasbeehcounter, PID: 30457
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.tasbeeh.tasbeehcounter/com.example.tasbeeh.tasbeehcounter.MainActivity}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.widget.RelativeLayout
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2426)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)
        at android.app.ActivityThread.-wrap11(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5443)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
     Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.widget.RelativeLayout
        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.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
        at com.example.tasbeeh.tasbeehcounter.MainActivity.onCreate(MainActivity.java:16)
        at android.app.Activity.performCreate(Activity.java:6245)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490) 
        at android.app.ActivityThread.-wrap11(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:148) 
        at android.app.ActivityThread.main(ActivityThread.java:5443) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 
     Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.widget.RelativeLayout
        at android.view.LayoutInflater.createView(LayoutInflater.java:645)
        at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
        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.example.tasbeeh.tasbeehcounter.MainActivity.onCreate(MainActivity.java:16) 
        at android.app.Activity.performCreate(Activity.java:6245) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490) 
        at android.app.ActivityThread.-wrap11(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:148) 
        at android.app.ActivityThread.main(ActivityThread.java:5443) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 
     Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance(Native Method)
        at android.view.LayoutInflater.createView(LayoutInflater.java:619)
        at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58) 
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694) 
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762) 
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
        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.example.tasbeeh.tasbeehcounter.MainActivity.onCreate(MainActivity.java:16) 
        at android.app.Activity.performCreate(Activity.java:6245) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490) 
        at android.app.ActivityThread.-wrap11(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:148) 
        at android.app.ActivityThread.main(ActivityThread.java:5443) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 
     Caused by: android.content.res.Resources$NotFoundException: Resource "com.example.tasbeeh.tasbeehcounter:drawable/ground" (7f060054) is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f060054 a=-1 r=0x7f060054}
        at android.content.res.Resources.loadDrawableForCookie(Resources.java:2605)
        at android.content.res.Resources.loadDrawable(Resources.java:2543)
        at android.content.res.TypedArray.getDrawable(TypedArray.java:870)
        at android.view.View.<init>(View.java:3951)
        at android.view.ViewGroup.<init>(ViewGroup.java:573)
        at android.widget.RelativeLayout.<init>(RelativeLayout.java:248)
        at android.widget.RelativeLayout.<init>(RelativeLayout.java:244)
        at android.widget.RelativeLayout.<init>(RelativeLayout.java:240)
        at java.lang.reflect.Constructor.newInstance(Native Method) 
        at android.view.LayoutInflater.createView(LayoutInflater.java:619) 
        at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58) 
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694) 
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762) 
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
        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.example.tasbeeh.tasbeehcounter.MainActivity.onCreate(MainActivity.java:16) 
        at android.app.Activity.performCreate(Activity.java:6245) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490) 
        at android.app.ActivityThread.-wrap11(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:148) 
        at android.app.ActivityThread.main(ActivityThread.java:5443) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 
06-02 22:38:58.350 30457-30457/com.example.tasbeeh.tasbeehcounter I/Process: Sending signal. PID: 30457 SIG: 9

Layout_xml file

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

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="180dp"
        android:scaleType="centerCrop"
        android:src="@drawable/mosque" />


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:orientation="horizontal">

        <LinearLayout 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="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:orientation="vertical">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:gravity="center_horizontal"
                android:text="Person 1"
                android:textColor="@color/colorPrimary"
                android:textSize="?android:textAppearanceLarge" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:gravity="center_horizontal"
                android:text="Quran Read"
                android:textColor="@color/colorPrimary"
                android:textSize="20sp"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/quranView1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:gravity="center_horizontal"
                android:text="0"
                android:textColor="@android:color/black"
                android:textSize="30sp" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <Button
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="8dp"
                    android:layout_marginRight="2dp"
                    android:layout_marginTop="8dp"
                    android:layout_weight="1"
                    android:background="@color/colorPrimary"
                    android:onClick="addQuran1"
                    android:text="Add"
                    android:textColor="@android:color/white" />

                <Button
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="2dp"
                    android:layout_marginRight="8dp"
                    android:layout_marginTop="8dp"
                    android:layout_weight="1"
                    android:background="@color/colorPrimary"
                    android:onClick="lessQuran1"
                    android:text="Less"
                    android:textColor="@android:color/white" />

            </LinearLayout>

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:gravity="center_horizontal"
                android:text="Durood Shareef"
                android:textColor="@android:color/black"
                android:textSize="20sp" />

            <TextView
                android:id="@+id/duroodView1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:gravity="center_horizontal"
                android:text="0"
                android:textColor="@android:color/black"
                android:textSize="30sp" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <Button
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="8dp"
                    android:layout_marginRight="2dp"
                    android:layout_marginTop="8dp"
                    android:layout_weight="1"
                    android:background="@color/colorPrimary"
                    android:onClick="addDurood1"
                    android:text="Add"
                    android:textColor="@android:color/white" />

                <Button
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="2dp"
                    android:layout_marginRight="8dp"
                    android:layout_marginTop="8dp"
                    android:layout_weight="1"
                    android:background="@color/colorPrimary"
                    android:onClick="lessDurood1"
                    android:text="Less"
                    android:textColor="@android:color/white" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <Button
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_marginLeft="8dp"
                    android:layout_marginRight="8dp"
                    android:layout_marginTop="8dp"
                    android:background="@color/colorPrimary"
                    android:onClick="resetThis1"
                    android:text="Reset This"
                    android:textColor="@android:color/white" />


            </LinearLayout>

        </LinearLayout>

        <LinearLayout 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="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:orientation="vertical">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:gravity="center_horizontal"
                android:text="Person 2"
                android:textColor="@color/colorPrimary"
                android:textSize="?android:textAppearanceLarge" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:gravity="center_horizontal"
                android:text="Quran Read"
                android:textColor="@color/colorPrimary"
                android:textSize="20sp"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/quranView2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:gravity="center_horizontal"
                android:text="0"
                android:textColor="@android:color/black"
                android:textSize="30sp" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <Button
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="8dp"
                    android:layout_marginRight="2dp"
                    android:layout_marginTop="8dp"
                    android:layout_weight="1"
                    android:background="@color/colorPrimary"
                    android:onClick="addQuran2"
                    android:text="Add"
                    android:textColor="@android:color/white" />

                <Button
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="2dp"
                    android:layout_marginRight="8dp"
                    android:layout_marginTop="8dp"
                    android:layout_weight="1"
                    android:background="@color/colorPrimary"
                    android:onClick="lessQuran2"
                    android:text="Less"
                    android:textColor="@android:color/white" />

            </LinearLayout>

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:gravity="center_horizontal"
                android:text="Durood Shareef"
                android:textColor="@android:color/black"
                android:textSize="20sp" />

            <TextView
                android:id="@+id/duroodView2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:gravity="center_horizontal"
                android:text="0"
                android:textColor="@android:color/black"
                android:textSize="30sp" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <Button
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="8dp"
                    android:layout_marginRight="2dp"
                    android:layout_marginTop="8dp"
                    android:layout_weight="1"
                    android:background="@color/colorPrimary"
                    android:onClick="addDurood2"
                    android:text="Add"
                    android:textColor="@android:color/white" />

                <Button
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="2dp"
                    android:layout_marginRight="8dp"
                    android:layout_marginTop="8dp"
                    android:layout_weight="1"
                    android:background="@color/colorPrimary"
                    android:onClick="lessDurood2"
                    android:text="Less"
                    android:textColor="@android:color/white" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <Button
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_marginLeft="8dp"
                    android:layout_marginRight="8dp"
                    android:layout_marginTop="8dp"
                    android:background="@color/colorPrimary"
                    android:onClick="resetThis2"
                    android:text="Reset This"
                    android:textColor="@android:color/white" />


            </LinearLayout>

        </LinearLayout>

    </LinearLayout>


</RelativeLayout>

MainActivity

package com.example.tasbeeh.tasbeehcounter;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    int quran = 0;
    int durood = 0;

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

    public void addQuran1 (View view){
        quran = quran + 1;
        displayQuran1(quran);
    }

    public void lessQuran1 (View view){
        quran = quran - 1;
        displayQuran1(quran);
    }

    public void addDurood1 (View view){
        durood = durood + 1;
        displayDurood1(durood);
    }

    public void lessDurood1 (View view){
        durood = durood - 1;
        displayDurood1(durood);
    }

    public void addQuran2 (View view){
        quran = quran + 1;
        displayQuran2(quran);
    }

    public void lessQuran2 (View view){
        quran = quran - 1;
        displayQuran2(quran);
    }

    public void addDurood2 (View view){
        durood = durood + 1;
        displayDurood2(durood);
    }

    public void lessDurood2 (View view){
        durood = durood - 1;
        displayDurood2(durood);
    }

    public void resetThis1 (View view) {
        quran = 0;
        durood = 0;
        displayQuran1(quran);
        displayDurood1(durood);
    }

    public void resetThis2 (View view) {
        quran = 0;
        durood = 0;
        displayQuran2(quran);
        displayDurood2(durood);
    }






    private void displayQuran1 (int number){
        TextView quran1displayview = (TextView) findViewById(R.id.quranView1);
        quran1displayview.setText("" + number);
    }

    private void displayDurood1 (int number){
        TextView durood1displayview = (TextView) findViewById(R.id.duroodView1);
        durood1displayview.setText("" + number);
    }

    private void displayQuran2 (int number){
        TextView quran2displayview = (TextView) findViewById(R.id.quranView2);
        quran2displayview.setText("" + number);
    }

    private void displayDurood2 (int number){
        TextView durood2displayview = (TextView) findViewById(R.id.duroodView2);
        durood2displayview.setText("" + number);
    }
}

2 Answers 2

2

If you see the exception root cause, the actual issue is

android.content.res.Resources$NotFoundException: Resource "com.example.tasbeeh.tasbeehcounter:drawable/ground" (7f060054) is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f060054 a=-1 r=0x7f060054}

In your layout.xml file, you have used a background for your root RelativeLayout.

<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_height="match_parent"
    android:layout_width="match_parent"
    android:background="@drawable/ground" <-- Here
    tools:context=".MainActivity">

Make sure you have added the drawable (file or xml) with name ground in your drawable or drawable-**** (mdpi, hdmi, xhdpi, xxhdpi and xxxhdpi) folder.

Tip: Try using vector drawables rather than static png files. More at: https://developer.android.com/guide/topics/graphics/vector-drawable-resources

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

2 Comments

Thank you very much for indicating and making my attention to drawable folder, the problem was not the same as you described but the things were pretty much linked with the design and colors as you told me ! :) I only changed android:textSize="@color/primary" android:textColor="@android:Color/white" To android:textSize="20sp" android:textColor="#3F51B5" and the problem was solved !
Aha! Cool. Also one other point to keep in mind is that it's always better to define your own colours than using the one's under @android:color. OEMs can change those colours to different variants on their devices.
0

drawable image might be in v24, delete this and place it without v24(simple).

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.