Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Floating Action Button causing error and crashing application

Tags:

java

android

When using the floating action button, my Android application crashes and throws an error. When I remove it, my application runs successfully, but I'd rather use the floating action button if I can.

This is my complete error log:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.supriya.hithere/com.example.supriya.hithere.MainActivity}: android.view.InflateException: Binary XML file line #32: Error inflating class android.support.design.widget.FloatingActionButton
     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 #32: Error inflating class android.support.design.widget.FloatingActionButton
     at android.view.LayoutInflater.createView(LayoutInflater.java:620)
     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
     at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:839)
     at android.view.LayoutInflater.rInflate(LayoutInflater.java:745)
     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.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276)
     at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
     at com.example.supriya.hithere.MainActivity.onCreate(MainActivity.java:47)
     at android.app.Activity.performCreate(Activity.java:5231)
     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1090)
     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: java.lang.reflect.InvocationTargetException
     at java.lang.reflect.Constructor.constructNative(Native Method)
     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
     at android.view.LayoutInflater.createView(LayoutInflater.java:594)
     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) 
     at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 
     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:839) 
     at android.view.LayoutInflater.rInflate(LayoutInflater.java:745) 
     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.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276) 
     at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
     at com.example.supriya.hithere.MainActivity.onCreate(MainActivity.java:47) 
     at android.app.Activity.performCreate(Activity.java:5231) 
     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1090) 
     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: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f02005f a=-1 r=0x7f02005f}
     at android.content.res.Resources.loadDrawable(Resources.java:2103)
     at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
     at android.widget.ImageView.<init>(ImageView.java:129)
     at android.widget.ImageButton.<init>(ImageButton.java:87)
     at android.support.design.widget.VisibilityAwareImageButton.<init>(VisibilityAwareImageButton.java:36)
     at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:114)
     at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:110)
     at java.lang.reflect.Constructor.constructNative(Native Method) 
     at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
     at android.view.LayoutInflater.createView(LayoutInflater.java:594) 
     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) 
     at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 
     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:839) 
     at android.view.LayoutInflater.rInflate(LayoutInflater.java:745) 
     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.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276) 
     at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
     at com.example.supriya.hithere.MainActivity.onCreate(MainActivity.java:47) 
     at android.app.Activity.performCreate(Activity.java:5231) 
     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1090) 
     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)

enter image description here enter image description here

like image 778
Snehal Gongle Avatar asked May 04 '16 06:05

Snehal Gongle


1 Answers

Make sure you are using AppCompatActivity instead of Activity, and AppCompat theme.

<style name="Base.AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

If you are using any attributes like backgroundTint or borderWidth for the FAB, make sure you are using app namespace.

app:backgroundTint="@color/accent_color"
app:borderWidth="0dp"
like image 101
Bob Avatar answered Sep 30 '22 20:09

Bob