Android之 运行时错误总结

No view found for id for fragment

java.lang.IllegalArgumentException: No view found for id 0x7f0e0097 (com.swm.newoxygen:id/hometab_project) for fragment ProjectFragment{7c7b890 #0 id=0x7f0e0097}
我的是在transaction.add(R.id.hometab_project, fragment).commit();
在commit之后布局文件还没有加载完,导致找不到这个容器R.id.hometab_project控件的ID

解决方案:新建一个线程,当这个FrameLayout控件已经添加到屏幕上的时候,在执行commit()方法.

new Thread(new Runnable() {
            @Override
            public void run() {
                while (!hometabFrameLayoutProject.isAttachedToWindow()) {
                }
               transaction.add(R.id.hometab_project, fragment).commit();
            }
        }).start();

The specified child already has a parent.

java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
产生原因是在onCreateViewHolder 的inflate()的root参数填写parent
解决应该写为null

@Override
        public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            mView = LayoutInflater.from(getContext()).inflate(R.layout.item_my_head, parent);
            mHolder = new MyHeadHolder(mView);
            return mHolder;
        }

Error:warning: Ignoring InnerClasses attribute for an anonymous inner classError:(com.baidu.lbsa

方法超过64K 异常
解决 在你的APP build.gradle下面加上multiDexEnabled true

defaultConfig{
    multiDexEnabled true
}
// 加上compile 'com.android.support:multidex:1.0.0'
dependencies{
    compile 'com.android.support:multidex:1.0.0'
}

你可能感兴趣的:(Android之 运行时错误总结)