Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error inflating layout of FloatingActionButton : NoSuchMethodException

So I'm getting an error inflating the layout, something about NoSuchMethodException. I've looked at other solutions to this and I've made sure that I've done the following, which I have, and I'm still getting the exception. Does anyone know what could be causing this??! I am completely lost, everything was working fine and then I updated my android studio and now I'm getting this error.

My activity is an AppCompatActivity

My app layout, using AppCompat:

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

My layout code, using app namespace for setting the background tint:

<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="@drawable/ic_add_white_18dp"
    app:backgroundTint="@color/colorPrimary"
    app:layout_behavior="Behaviors.ScrollAwareFABBehavior"/>

<include layout="@layout/content_main" />

This is my gradle build file:

compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.google.android.gms:play-services:9.4.0'

Here is my stack trace:

java.lang.NoSuchMethodError: android.support.v7.widget.AppCompatImageHelper.<init>(Landroid/widget/ImageView;Landroid/support/v7/widget/AppCompatDrawableManager;)V
at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:133)
at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:110)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:465)
at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:172)
at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:105)
at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:186)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:334)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:345)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:245)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:858)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater_Delegate.parseInclude(LayoutInflater_Delegate.java:197)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:902)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:854)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:324)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:429)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:389)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:548)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:533)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:966)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:533)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate$53(RenderTask.java:659)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
like image 201
Riptyde4 Avatar asked Oct 29 '16 21:10

Riptyde4


2 Answers

I have exactly the some problem, it was random and it was today after mindlesly selecting "ok" on Android studio about something related to downloading stuff. :P

I tried to upgrate SDK build tools (without using them), and rebuilted the project but no luck.

Then, i upgraded to JAVA 1.8, moved to compileSdkVersion 24 and support library 24.2.1 and it worked.

So chances are that Google broke something on last update.

like image 67
Nikiforos Avatar answered Sep 24 '22 19:09

Nikiforos


set compileSdkVersion to 24 and then change the

compile 'com.android.support:design:23.4.0'

to

compile 'com.android.support:design:24.2.0'

then sync your project, it will resolve the issue.

like image 41
Abubakar Avatar answered Sep 25 '22 19:09

Abubakar