setContentView导致IllegalStateException

时间:2017-05-30 13:16:52

标签: android illegalstateexception

我正在使用Android API 19的设备SM-G360H的一个用户的崩溃报告,并且它的发生非常罕见。我甚至不知道如何重现这个问题。

我的代码:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.my_activity);
    ButterKnife.inject(this);
    // Other code
}

对于我的XML:

<ImageView
                android:layout_marginTop="20dp"
                android:layout_width="8dp"
                android:layout_height="8dp"
                android:src="@drawable/mydrawable"
                android:layout_alignRight="@id/rightView"
                android:layout_alignEnd="@id/rightView"
                android:layout_marginRight="8dp"
                android:layout_marginEnd="8dp"/>
<!-- other views -->
<ImageView
        android:id="@+id/imageViewId"
        android:layout_width="match_parent"
        android:layout_height="@dimen/viewHeight"
        android:scaleType="fitXY"
        android:layout_gravity="bottom"
        app:layout_behavior="@string/my_custome_behaviour"/>

setContentView(R.layout.my_activity);

引发异常

这是我的堆栈跟踪:

Caused by java.lang.IllegalStateException: State: FLUSHED
java.nio.charset.CharsetEncoder.illegalStateException (CharsetEncoder.java:670)
java.nio.charset.CharsetEncoder.encode (CharsetEncoder.java:360)
java.io.OutputStreamWriter.drainEncoder (OutputStreamWriter.java:197)
java.io.OutputStreamWriter.close (OutputStreamWriter.java:139)
android.content.res.Resources.loadDrawable (Resources.java:3385)
android.content.res.TypedArray.getDrawable (TypedArray.java:614)
android.widget.ImageView.<init> (ImageView.java:134)
android.support.v7.widget.AppCompatImageView.<init> (AppCompatImageView.java:57)
android.support.v7.widget.AppCompatImageView.<init> (AppCompatImageView.java:53)
android.support.v7.app.AppCompatViewInflater.createView (AppCompatViewInflater.java:106)
android.support.v7.app.AppCompatDelegateImplV9.createView (AppCompatDelegateImplV9.java:1013)
android.support.v7.app.AppCompatDelegateImplV9.onCreateView (AppCompatDelegateImplV9.java:1072)   android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView (LayoutInflaterCompatHC.java:44)
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:691)
android.view.LayoutInflater.rInflate (LayoutInflater.java:762)
android.view.LayoutInflater.rInflate (LayoutInflater.java:771)
android.view.LayoutInflater.rInflate (LayoutInflater.java:771)
android.view.LayoutInflater.rInflate (LayoutInflater.java:771)
android.view.LayoutInflater.inflate (LayoutInflater.java:499)
android.view.LayoutInflater.inflate (LayoutInflater.java:398)
android.view.LayoutInflater.inflate (LayoutInflater.java:354)
android.support.v7.app.AppCompatDelegateImplV9.setContentView (AppCompatDelegateImplV9.java:284)
android.support.v7.app.AppCompatActivity.setContentView (AppCompatActivity.java:140)

0 个答案:

没有答案