Stephanie-JK Stephanie-JK - 1 month ago 13
Java Question

I only created a blank activity and the app keeps crashing. The logcat shows several FATAL EXCEPTIONS

I'm sort of new in android development. I have no idea why my app keeps crashing, the gradle doesn't show any error but the logcat has a lots of exceptions. And honestly, I don't understand most of the logcat details.

How do I stop my App from crashing? And what is causing it to crash?
This is the logcat details:

10-25 11:56:32.870 3126-3126/? I/art: Not late-enabling -Xcheck:jni (already on)
10-25 11:56:32.870 3126-3126/? I/art: Late-enabling JIT
10-25 11:56:32.896 3126-3126/? I/art: JIT created with code_cache_capacity=2MB compile_threshold=1000
10-25 11:56:33.050 3126-3133/? I/art: Debugger is no longer active
10-25 11:56:33.372 3126-3126/? W/System: ClassLoader referenced unknown path: /data/app/com.example.subinasharma.myapplication-2/lib/x86
10-25 11:56:35.029 3126-3133/com.example.subinasharma.myapplication W/art: Suspending all threads took: 15.151ms
10-25 11:56:35.071 3126-3126/com.example.subinasharma.myapplication D/AndroidRuntime: Shutting down VM
10-25 11:56:35.075 3126-3126/com.example.subinasharma.myapplication E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.subinasharma.myapplication, PID: 3126
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.subinasharma.myapplication/com.example.subinasharma.myapplication.MainActivity}: android.view.InflateException: Binary XML file line #15: 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 #15: 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.subinasharma.myapplication.MainActivity.onCreate(MainActivity.java:17)
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.subinasharma.myapplication.MainActivity.onCreate(MainActivity.java:17) 
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) 
10-25 11:56:35.883 3126-3133/com.example.subinasharma.myapplication W/art: Suspending all threads took: 35.182ms
10-25 11:56:43.252 3126-3126/com.example.subinasharma.myapplication I/Process: Sending signal. PID: 3126 SIG: 9


And there are two layouts created by Android Studio itself,
Activity_Main.xml:

<?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="com.example.subinasharma.myapplication.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 another Content_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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.subinasharma.myapplication.MainActivity"
tools:showIn="@layout/activity_main">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
</RelativeLayout>

Answer

@ Stephanie-JK when you create a new project i think you have select a BASE Activity hence arrive this problem. Next time when you create a new project please select a Empty Activity then its generate a only one Layout and your problem resolve..thanks