android – 错误膨胀FloatingActionButton的布局:NoSuchMethodException

前端之家收集整理的这篇文章主要介绍了android – 错误膨胀FloatingActionButton的布局:NoSuchMethodException前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
所以我在布局时出现了错误,这是关于NoSuchMethodException的.我已经看过其他解决方案,我已经确定我已经完成了以下操作,我已经完成了这个例外.有谁知道这可能导致什么?我完全迷失了,一切正常,然后我更新了我的 android工作室,现在我收到了这个错误.

我的活动是AppCompatActivity

我的应用布局,使用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>

我的布局代码,使用app命名空间设置背景色调:

<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" />

这是我的gradle构建文件

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'

这是我的堆栈跟踪:

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)

解决方法

我确实有一些问题,它是随机的,今天是在Android工作室上关于下载内容相关的东西后心不在焉地选择“确定”. :P

我尝试升级SDK构建工具(不使用它们),并重建项目但没有运气.

然后,我升级到JAVA 1.8,转移到compileSdkVersion 24并支持库24.2.1并且它工作正常.

因此谷歌有可能在上次更新时破坏了一些东西.

原文链接:https://www.f2er.com/android/318495.html

猜你在找的Android相关文章