特定设备上的android.view.InflateException

时间:2018-01-24 05:46:32

标签: android android-fragments android-inflate

首先,我确实看过其他帖子并试图找到答案,但没有一个帮助过我。所以我想提出我的问题。在开发人员控制台崩溃审查期间,我注意到我的应用程序崩溃在特定的2设备上,另一台具有相同操作系统的设备只能在下面显示错误的设备上正常工作。

android.view.InflateException: 
  at android.view.LayoutInflater.inflate (LayoutInflater.java:543)
  at android.view.LayoutInflater.inflate (LayoutInflater.java:427)
  at com.parshtech.shadimela.fragment.ProfileFragmentNew.onCreateView (ProfileFragmentNew.java:80)
  at android.support.v4.app.Fragment.performCreateView (Fragment.java:2261)
  at android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManager.java:1419)
  at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState (FragmentManager.java:1750)
  at android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManager.java:1819)
  at android.support.v4.app.BackStackRecord.executeOps (BackStackRecord.java:797)
  at android.support.v4.app.FragmentManagerImpl.executeOps (FragmentManager.java:2590)
  at android.support.v4.app.FragmentManagerImpl.executeOpsTogether (FragmentManager.java:2377)
  at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute (FragmentManager.java:2332)
  at android.support.v4.app.FragmentManagerImpl.execSingleAction (FragmentManager.java:2209)
  at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss (BackStackRecord.java:649)
  at android.support.v4.app.FragmentPagerAdapter.finishUpdate (FragmentPagerAdapter.java:145)
  at android.support.v4.view.ViewPager.populate (ViewPager.java:1238)
  at android.support.v4.view.ViewPager.populate (ViewPager.java:1086)
  at android.support.v4.view.ViewPager.onMeasure (ViewPager.java:1616)
  at android.view.View.measure (View.java:18811)
  at android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:5952)
  at android.support.design.widget.CoordinatorLayout.onMeasureChild (CoordinatorLayout.java:719)
  at android.support.design.widget.HeaderScrollingViewBehavior.onMeasureChild (HeaderScrollingViewBehavior.java:91)
  at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onMeasureChild (AppBarLayout.java:1361)
  at android.support.design.widget.CoordinatorLayout.onMeasure (CoordinatorLayout.java:789)
  at android.view.View.measure (View.java:18811)
  at android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:5952)
  at android.widget.FrameLayout.onMeasure (FrameLayout.java:194)
  at android.support.v7.widget.ContentFrameLayout.onMeasure (ContentFrameLayout.java:139)
  at android.view.View.measure (View.java:18811)
  at android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:5952)
  at android.widget.LinearLayout.measureChildBeforeLayout (LinearLayout.java:1465)
  at android.widget.LinearLayout.measureVertical (LinearLayout.java:748)
  at android.widget.LinearLayout.onMeasure (LinearLayout.java:630)
  at android.view.View.measure (View.java:18811)
  at android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:5952)
  at android.widget.FrameLayout.onMeasure (FrameLayout.java:194)
  at android.view.View.measure (View.java:18811)
  at android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:5952)
  at android.widget.LinearLayout.measureChildBeforeLayout (LinearLayout.java:1465)
  at android.widget.LinearLayout.measureVertical (LinearLayout.java:748)
  at android.widget.LinearLayout.onMeasure (LinearLayout.java:630)
  at android.view.View.measure (View.java:18811)
  at android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:5952)
  at android.widget.FrameLayout.onMeasure (FrameLayout.java:194)
  at com.android.internal.policy.PhoneWindow$DecorView.onMeasure (PhoneWindow.java:2643)
  at android.view.View.measure (View.java:18811)
  at android.view.ViewRootImpl.performMeasure (ViewRootImpl.java:2127)
  at android.view.ViewRootImpl.measureHierarchy (ViewRootImpl.java:1243)
  at android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:1479)
  at android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:1134)
  at android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:6050)
  at android.view.Choreographer$CallbackRecord.run (Choreographer.java:860)
  at android.view.Choreographer.doCallbacks (Choreographer.java:672)
  at android.view.Choreographer.doFrame (Choreographer.java:608)
  at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:846)
  at android.os.Handler.handleCallback (Handler.java:742)
  at android.os.Handler.dispatchMessage (Handler.java:95)
  at android.os.Looper.loop (Looper.java:154)
  at android.app.ActivityThread.main (ActivityThread.java:5527)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:739)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:629)
Caused by: android.view.InflateException: 
  at android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:786)
  at android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:708)
  at android.view.LayoutInflater.rInflate (LayoutInflater.java:839)
  at android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:802)
  at android.view.LayoutInflater.inflate (LayoutInflater.java:519)
Caused by: android.content.res.Resources$NotFoundException: 
  at android.content.res.Resources.loadDrawableForCookie (Resources.java:2646)
  at android.content.res.Resources.loadDrawable (Resources.java:2580)
  at android.content.res.MiuiResources.loadDrawable (MiuiResources.java:387)
  at android.content.res.TypedArray.getDrawable (TypedArray.java:872)
  at android.widget.TextView.<init> (TextView.java:888)
  at android.widget.Button.<init> (Button.java:109)
  at android.widget.Button.<init> (Button.java:105)
  at android.support.v7.widget.AppCompatButton.<init> (AppCompatButton.java:70)
  at android.support.v7.widget.AppCompatButton.<init> (AppCompatButton.java:66)
  at android.support.v7.app.AppCompatViewInflater.createView (AppCompatViewInflater.java:109)
  at android.support.v7.app.AppCompatDelegateImplV9.createView (AppCompatDelegateImplV9.java:1016)
  at android.support.v7.app.AppCompatDelegateImplV9.onCreateView (AppCompatDelegateImplV9.java:1073)
  at android.view.LayoutInflater$FactoryMerger.onCreateView (LayoutInflater.java:189)
  at android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:750)

在回顾其他类似帖子后,我发现很多人都有Fragment XML的问题,但在我的场景中我没有看到任何问题。这是我的片段XML。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/profileFragment"
android:background="@drawable/logo_grey"
tools:context="com.parshtech.shadimela.fragment.ProfileFragmentNew">
<android.support.design.widget.FloatingActionButton
    android:theme="@style/AppTheme.FloatingAccentButtonOverlay"
    android:id="@+id/removeFilter"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentEnd="true"
    android:layout_below="@+id/search"
    android:visibility="gone"
    android:src="@drawable/removefilter" />
<android.support.v7.widget.RecyclerView
    android:id="@+id/recycler_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:clickable="true"
    android:focusable="true"
    android:layout_marginBottom="@dimen/activity_horizontal_margin"
    android:clipToPadding="false"
    android:layout_marginTop="@dimen/activity_horizontal_margin"
    android:layout_marginRight="8dp"
    android:layout_marginLeft="8dp"
    android:outlineProvider="bounds"   />

<ProgressBar
    android:id="@+id/progress_bar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:visibility="gone"
    android:layout_centerInParent="true"/>
<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="50dp"
    android:id="@+id/dwnldData"
    android:visibility="gone"
    android:background="@android:color/transparent"
    android:drawableTop="@drawable/download_black"
    android:layout_below="@+id/showcand"
    android:text="@string/download_data"
    android:textSize="16sp"
    android:layout_centerHorizontal="true"/>


<android.support.design.widget.FloatingActionButton
    android:theme="@style/AppTheme.FloatingAccentButtonOverlay"
    android:id="@+id/refreshdata"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentEnd="true"
    android:visibility="gone"
    android:layout_alignParentTop="true"
    android:src="@drawable/refresh" />

<android.support.design.widget.FloatingActionButton
    android:theme="@style/AppTheme.FloatingAccentButtonOverlay"
    android:id="@+id/search"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentEnd="true"
    android:layout_below="@+id/refreshdata"
    android:src="@drawable/search" />

下面是我正在获得异常的java代码行 -

public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
       view = inflater.inflate(R.layout.fragment_profile_new, container, false);

1 个答案:

答案 0 :(得分:0)

我认为您Button android:layout_below="@+id/showcand"但我发现您的xml没有此ID showcand,因此您可以再次删除此尝试。希望能帮到你