android编译报错
来源:互联网 发布:数据库安全管理规定 编辑:程序博客网 时间:2024/05/17 12:22
01)Error parsing XML: unbound prefix
原因之一:拼写错误。例如:android写成androd之类。
原因之二:xmlns没有添加。有的时候,自定了一些view,且新加了一些自定义的命名,那么需要添加声明到根上。如果忘了添加也会报这个错误。
xmlns:calendar=”http://schemas.android.com/apk/res-auto”
2)没有R文件的错误。
检查是否编译了项目。Android studio有时候没有编译就会报出没有R文件的错误。
检查带代码中包名是否正确。有时候从其他地方复制代码过来时连带了包名,也会报出R文件找不到。
检查布局文件是否有语法错误。布局文件有语言错误时也会导致R文件错误。
软件莫名有问题,重建项目试试。
Android studio左上角有个选项,一般我们可能是选的Android模式,选择Packages模式找到你的项目,里面就可以看到R文件了
build–generated–>source–>r–>debug–>R
3.线程中更新主界面异常
e = android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
解决方案:使用handler + sendmessage方式来调用主界面中的方法进行界面刷新
4.android.os.networkonmainthreadexception
在android2.3之后 在主线程中必须使用另一个线程 如handler机制,或者异步任务获取网络数据
如果你访问网络的操作 必须放在主线程中执行,那么 在oncreate()中添加
if (GetVersion.GetSystemVersion() > 2.3) { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() .detectDiskReads().detectDiskWrites().detectNetwork() .penaltyLog().build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() .detectLeakedSqlLiteObjects().penaltyLog().penaltyDeath() .build());}这样 高版本中也可以在主线程中执行网络操作了
5.java.lang.IllegalArgumentException:
View=com.android.internal.policy.impl.PhoneWindow$DecorView{a964d33 V.E..... R.....ID 0,0-304,223} not attached to window manager
http://www.bubuko.com/infodetail-1120955.html
http://blog.csdn.net/yuxiaohui78/article/details/38076447
当用户在各个tab page间快速切换的时候,ProgressDialog 使用的context就很不安全。
会遇到调用 dialog.dismiss 和 dialog.show(); 的时候无法attach到Window Manager.
原因:在切换的时候,dialog还没有完成所有的调用,所对应的context已经被destroy或正在destroy。
使用ApplicationContext,(context.getApplicationContext()),这个context无法用于ProgressDialog和Toast。会直接导致crash。
目前的解决方法是,先检查context对应的Activity的状态,如果不可用就停止dialog操作:
private boolean isValidContext(Context c) { Activity a = (Activity) c; //a.isDestroyed()方法是android17之后才有的接口 if (Build.VERSION.SDK_INT >= 17) { if (a.isDestroyed() || a.isFinishing()) { return false; } else { return true; } } else { if (a.isFinishing()) { return false; } else { return true; } } }
6.Android开发 解决AlertDialog中的EditText无法调出输入法的问题
在show之前添加view,之后再window.setContentView,使用同一个布局文件
LayoutInflater inflater=(LayoutInflater)MainActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);View layout = inflater.inflate(R.layout.dialog_store_layout, null);StoreDialog.setView(layout);StoreDialog.show();Window dialogWindow = StoreDialog.getWindow();dialogWindow.setContentView(R.layout.dialog_store_layout);
- Android 编译报错
- android编译报错
- Android Studio 编译报错
- android 5.0编译报错
- android编译报错问题
- android studio编译报错
- Android Studio编译报错
- vlc-android 编译报错
- cocos2dx android编译报错
- Android Studio编译报错:
- android 修改api后编译报错
- 编译android vbox_x86-eng 报错
- cocos2dx android编译报错undefine
- android 编译报错:out of space?
- 编译android时,遇到报错
- android 导入so文件,编译报错
- android studio 编译运行报错:
- android studio 编译运行报错
- Servlet 基础03
- Activity之间切换动画
- ArcGis 读取Shape文件 代码
- iOS 面试总结
- 利用css写出二级导航
- android编译报错
- 六轴系统中陀螺仪输出的角速度的一些问题
- C# 在Word文档中生成条形码
- 网页中导航栏实现子菜单下拉效果
- Android 中的Handler详解
- RedHat系统下安装CentOS系统的yum
- Android SDK各个版本API的特性及兼容性
- servlet客户端http请求及响应及httpservletrequest,httpservletresponse详解
- Oracle11.2新特性之INSERT提示IGNORE_ROW_ON_DUPKEY_INDEX