错误:java.lang.ExceptionInInitializerError

时间:2016-11-25 12:33:57

标签: java android android-fragments

在Android 4(Jelly bean)手机中测试时出现此错误。然而它在Android 5(Lollipop)中运行良好。我在SO中搜索了几个相关的问题,但没有帮助我。

ERROR:

11-25 17:51:40.980 824-824/com.ficean.android.ficean E/AndroidRuntime: FATAL EXCEPTION: main
                                                                   java.lang.ExceptionInInitializerError
                                                                       at java.lang.reflect.Constructor.constructNative(Native Method)
                                                                       at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
                                                                       at android.view.LayoutInflater.createView(LayoutInflater.java:593)
                                                                       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:693)
                                                                       at android.view.LayoutInflater.rInflate(LayoutInflater.java:752)
                                                                       at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
                                                                       at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
                                                                       at com.ficean.android.ficean.Home.tab3.onCreateView(tab3.java:82)
                                                                       at android.support.v4.app.Fragment.performCreateView(Fragment.java:2080)
                                                                       at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1108)
                                                                       at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1290)
                                                                       at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:801)
                                                                       at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1638)
                                                                       at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:679)
                                                                       at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:166)
                                                                       at android.support.v4.view.ViewPager.populate(ViewPager.java:1240)
                                                                       at android.support.v4.view.ViewPager.populate(ViewPager.java:1088)
                                                                       at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1614)
                                                                       at android.view.View.measure(View.java:15562)
                                                                       at android.widget.LinearLayout.measureVertical(LinearLayout.java:833)
                                                                       at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
                                                                       at android.view.View.measure(View.java:15562)
                                                                       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5107)
                                                                       at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
                                                                       at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
                                                                       at android.view.View.measure(View.java:15562)
                                                                       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5107)
                                                                       at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1396)
                                                                       at android.widget.LinearLayout.measureVertical(LinearLayout.java:681)
                                                                       at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
                                                                       at android.view.View.measure(View.java:15562)
                                                                       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5107)
                                                                       at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
                                                                       at android.view.View.measure(View.java:15562)
                                                                       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5107)
                                                                       at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1396)
                                                                       at android.widget.LinearLayout.measureVertical(LinearLayout.java:681)
                                                                       at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
                                                                       at android.view.View.measure(View.java:15562)
                                                                       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5107)
                                                                       at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
                                                                       at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2423)
                                                                       at android.view.View.measure(View.java:15562)
                                                                       at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2006)
                                                                       at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1245)
                                                                       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1420)
                                                                       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1138)
                                                                       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4655)
                                                                       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
                                                                       at android.view.Choreographer.doCallbacks(Choreographer.java:555)
                                                                       at android.view.Choreographer.doFrame(Choreographer.java:525)
                                                                       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
                                                                       at android.os.Handler.handleCallback(Handler.java:615)
                                                                       at android.os.Handler.dispatchMessage(Handler.java:92)
                                                                       at android.os.Looper.loop(Looper.java:177)
                                                                       at android.app.ActivityThread.main(ActivityThread.java:4944)
                                                                       at java.lang.reflect.Method.invokeNative(Native Method)
                                                                       at java.lang.reflect.Method.invoke(Method.java:511)
                                                                    at com.android.internal.os.ZygoteInit$MethodAnd

我在一个名为tab3.java的片段中收到此错误,同时膨胀相关的xml布局。

CODE:

    @Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.tab3, container, false);//ERROR line
    setHasOptionsMenu(true);
    return v;
}

tab3.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/white">

    <android.support.v7.widget.RecyclerView
    android:id="@+id/recyclerview_contacts_tab3_fragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="vertical" />


<xyz.danoz.recyclerviewfastscroller.vertical.VerticalRecyclerViewFastScroller
    android:id="@+id/fast_scroller"
    android:layout_width="@dimen/scrollfastwidth"
    android:layout_height="match_parent"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    />
<ProgressBar
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/loadnumbersprogress_for_tab3_fragment"
    android:layout_centerInParent="true"
    style="@style/Widget.AppCompat.ProgressBar"
    android:visibility="invisible"
    />
<android.support.design.widget.FloatingActionButton
    android:id="@+id/floatingbutton_for_tab3_fragment"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignParentBottom="true"
    android:layout_alignParentEnd="true"
    app:fabSize="normal"
    android:layout_margin="@dimen/activity_horizontal_margin"
    app:backgroundTint="@color/appcolor"
    android:src="@drawable/ic_person_add_white_24dp"
    />
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="@dimen/activity_horizontal_margin"
    android:layout_marginRight="@dimen/activity_horizontal_margin"
    android:layout_marginBottom="@dimen/activity_horizontal_margin"
    android:textSize="@dimen/Header_title_size"
    android:text=""
    android:layout_centerInParent="true"
    android:id="@+id/reportertab3"
    android:gravity="center"
    /></RelativeLayout>

0 个答案:

没有答案