Android ListFragment w / Fabric崩溃

时间:2016-02-29 19:55:42

标签: android twitter-fabric

我刚刚开始搞乱Twitter的Fabric,无论我做什么,我似乎无法解决这个崩溃。我让它在一个活动中工作,但使用片段它不起作用,它适合教程。这是我的片段:

    public class ContentFragment extends ListFragment {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        TwitterAuthConfig authConfig = new TwitterAuthConfig("XXXXXX", "XXXXXX");
        Fabric.with(MainActivity.getInstance(), new TwitterCore(authConfig), new TweetUi(), new Twitter(authConfig));

        UserTimeline userTimeline = new UserTimeline.Builder().screenName("twitteruser").build();
        TweetTimelineListAdapter adapter = new TweetTimelineListAdapter.Builder(MainActivity.getInstance()).setTimeline(userTimeline).build();
        setListAdapter(adapter);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_content, container, false);
    }
  }

堆栈跟踪如下:

29 19:52:22.232 3781-3781/? E/AndroidRuntime: FATAL EXCEPTION: main
                                             Process: uk.co.lukewizzy.xxx, PID: 3781
                                             java.lang.RuntimeException: Unable to start activity ComponentInfo{uk.co.lukewizzy.xxx/uk.co.lukewizzy.xxx.layouts.MainActivity}: java.lang.IllegalStateException: Must start TweetUi Kit in Fabric.with().
                                                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
                                                 at android.app.ActivityThread.access$800(ActivityThread.java:151)
                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
                                                 at android.os.Handler.dispatchMessage(Handler.java:102)
                                                 at android.os.Looper.loop(Looper.java:135)
                                                 at android.app.ActivityThread.main(ActivityThread.java:5254)
                                                 at java.lang.reflect.Method.invoke(Native Method)
                                                 at java.lang.reflect.Method.invoke(Method.java:372)
                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
                                              Caused by: java.lang.IllegalStateException: Must start TweetUi Kit in Fabric.with().
                                                 at com.twitter.sdk.android.tweetui.TweetUi.checkInitialized(TweetUi.java:134)
                                                 at com.twitter.sdk.android.tweetui.TweetUi.getInstance(TweetUi.java:74)
                                                 at com.twitter.sdk.android.tweetui.UserTimeline$Builder.<init>(UserTimeline.java:106)
                                                 at uk.co.lukewizzy.xxx.layouts.ContentFragment.onCreate(ContentFragment.java:27)
                                                 at android.app.Fragment.performCreate(Fragment.java:2031)
                                                 at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:863)
                                                 at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
                                                 at android.app.BackStackRecord.run(BackStackRecord.java:834)
                                                 at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1452)
                                                 at android.app.Activity.performStart(Activity.java:6005)
                                                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2288)
                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) 
                                                 at android.app.ActivityThread.access$800(ActivityThread.java:151) 
                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) 
                                                 at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                 at android.os.Looper.loop(Looper.java:135) 
                                                 at android.app.ActivityThread.main(ActivityThread.java:5254) 
                                                 at java.lang.reflect.Method.invoke(Native Method) 
                                                 at java.lang.reflect.Method.invoke(Method.java:372) 
                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 

0 个答案:

没有答案