您的位置:首页 > 移动开发 > Android开发

android常见错误(实时更新)

2015-09-21 07:55 459 查看
学习安卓有小段时日啦,为了避免总是遇到相应的错误,特此做了这个小记录。。。。赏脸围观吧。

1.xml aborting build :架构错误,
在布局时的常见错误xml缺少标签或者符号
2.Error: No resource found that matches the given name (at 'background' with value '@drawable/S50910c'):背景图片命名包含大写字母或者“—”线
3.void is an invalid type for the variable newactivity
这是zaiactivity编辑时出现的错误,原因:

可变newactivity是空的类型无效
我在定义一个Button监听时出现错误
原代码:

@Overrides
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

public void newactivity(View v){

Intent intent = new Intent(this,NewactivityMainActivity.class);

startActivity(intent);

}

}

解决方法:写到方法里面了T..T,应该写在类里;
4.在activity里要获得EditText输入值时候的错误

原因:The method findViewByid(int) is undefined for the type MainActivity
方法findViewById(int)是未定义的类型的主要活动
原代码:
manheight = (EditText)findViewByid(R.id.manheightnum);
解决方案:不知道为什么按照提示乱点就好了。。。。。
5.如何去除 title呢
在注册文件里MainActivity里面加注
android:theme="@android:style/Theme.Black.NoTitleBar"
作用:同时去除background和title和相应高度。
6. Please check logcat output for more details.
Installation failed due to invalid URI!

jar包冲突,删除libs中的v4包

7.

Installation failed due to invalid APK file!
由于无效的APK文件安装失败!

8.R文件丢失怎么办!
有时候总是无缘无故的报错,比如手贱删除了xml中的某个id或者让R文件中出现命名冲突或者大写文件名了,eclipse这个傻蛋就不知道如何弄了,如果这时候你在手贱clean一下,那么eclips就将R文件彻底删除,怎么办呢
经多次研究后发现,它不仅删除了R文件,还会自己写一个
import android.R
因此它又默认可以找到R文件,但是在gen文件中也没有,这时候只要删除这句话并刷新就好了
import android.R;
删了它!!!!!!!
9.

错误提示:Your
content must have a ListView whose id attribute is 'android.R.id.list'

对于以上错误,其实可能是因为我们要实现对ListView中setOnItemClick的事件监听而去继承了LiseActivity,但是却没有ListView的标签,只要在布局文件中添加定制Layout的代码,即将ListView的id设置为“@android:id/list”或android:id="@id/android:list",这时可以用getListView来获取ListView的对象了。
10.

当遇到“Your content mush have a listView whose id attribute is 'android.R.id.list'“异常时:

一般在继承ListActivity时候,我们可以不指定xml的layout文件,但是当我们使用setContentView(xx)指定xml的layout时,确定在此xml文件中我们定义如下view

Xml代码






<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >

</ListView>

<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >

</ListView>


否则就会出现异常。

原因:因为ListActivity中已经绑定了默认的ListView,如果我们重新给Activity绑定Layout时,需要保证已经存在的父类中的视图工作正常,所以需要加上上述视图。

。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。朱芮成
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: