用android Studio 的时候遇到的一些错误。

finished with non-zero exit value 2

原因是引入了重复的包
检查complie
 
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.xxx/com.android.xxx.Activity.Activity_Login}: android.view.InflateException: Binary XML file line #46: Error inflating class android.support.design.widget.TabLayout
 
这个错误的原因是因为当前sdk版本和引用的包版本 不匹配
 
R文件丢失
第一个 先去看看是不是有xml文件错误
其次 在修正
 
java.lang.SecurityException: Permission Denial: opening provider
错误是无法访问通话权限
 
设置按压变色的效果后崩溃
原因:不能在selector的xml里面直接设置颜色,要用@color/xxx 来调用
 
Android报错ViewPager: Can't Change Tag of Fragment的解决方法
是由FragmentPagerAdapter的instantiateItem方法造成的,这个方法需要给fragment编号,
报错写得很清楚Can’t change tag of fragment PageFragment{42ef29a8 #14 id=0x7f060052 android:switcher:2131099730:22}: was android:switcher:2131099730:22 now android:switcher:2131099730:17
就是你的这个fragment的编号是android:switcher:2131099730:17,而你可能又给它设置一个tag,导致报错
 
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
出现这个错误说明已经有一个父view了,我是在addview的时候报错的,所以需要先释放,调下remove方法
 
 
 

android.view.InflateException: Binary XML file line

这种情况有很多,我遇到的情况是在自定义的时候构造函数中有问题比如

(Context context, AttributeSet attrs) {
super(context, attrs);

InitView();
}
AttributeSet 参数的作用是在xml中引用时调用其中的属性,所以一定要加,而自定义view中有很多个重载,所以要选对

 

posted @ 2017-03-07 17:07  conker  阅读(867)  评论(0编辑  收藏  举报