x86 android baocuo,Android报错

本文总结了Android开发中遇到的一些典型问题及其解决方法,包括:Intel HAXM安装失败、jarlist.cache写入错误、向下兼容问题、布局文件预览失败、JUnit测试配置、文件写入错误、录音功能异常等,并提供了详细的解决步骤和注意事项。
摘要由CSDN通过智能技术生成

1. Starting emulator for AVD 'new'emulator: ERROR: x86 emulation currently requires hardware acceleration!Please ensure Intel HAXM is properly installed and usable.CPU acceleration status: HAX kernel module is not installed!

发生情景:创建 Android 模拟器,模拟器 CPU 处理器选择了 Intel 处理器。启动报错

问题原因:电脑上没有安装Intel HAXM

解决方案:找到Android sdk所在的目录。其下有extras\intel\Hardware_Accelerated_Execution_Manager

把该目录下的intelhaxm.exe安装一下

2.unable to write jarlist cache file F:\workspace\Android\appcompat_v7\bin\jarlist.cache

发生情景:创建项目,最低兼容选择 2.2,最高选择 4.4

问题原因:向下兼容

解决方案:

方法1:将最低兼容选择同级的,即也是选择 4.x 系列的即可

[不推荐,因为 Android 应用都是要考虑向下兼容的]

方法2:E:\SL\appcompat_v7\res\values-v21\themes_base.xml:191:

说明,要求你的 sdk 为 android5.0 的 sdk,因此,需要把 Property 中 Android 的对应版本改成 5.0 才行

即:将 project.properties 中 target 改为 android-21

3.Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton'.

......

发生情景:创建项目,最低兼容选择 2.2,最高选择 4.4

问题原因:向下兼容, 查看项目目录结构,发现 gen 目录下没有 R.java 文件

解决方案:

方法1:将最低兼容选择同级的,即也是选择 4.x 系列的即可

[不推荐,因为 Android 应用都是要考虑向下兼容的]

方法2:E:\SL\appcompat_v7\res\values-v21\themes_base.xml:191:

说明,要求你的 sdk 为 android5.0 的 sdk,因此,需要把 Property 中 Android 的对应版本改成 5.0 才行

即:将 project.properties 中 target 改为 android-21

4. This version of the rendering library is more recent thanyour version of ADT plug-in. Please update ADT plug-in

发生情景:

eclipse 创建 android 项目时,预览 layout.xml 文件时提示: This version of the rendering library is more recent than your version of ADT plug-in. Please update ADT plug-in,导致无法正常预览布局文件

问题原因:编译的 SDK 版本为 4.4w,SDK版本过高,ADT版本过低

解决方案:

方法1:打开 layout 文件中的.xml文件,找到选择 android 版本按钮,改变 android 版本,我们改为4.4.2的版本。

方法2:打开 android 项目中的 project.properties,直接修改版本:target=android-19

5.  OpSQLite does not specify a android.test.InstrumentationTestRunner instrumentation or does not declare uses-library android.test.runner in its AndroidManifest.xml

发生情景:运行 OpSOLite 的测试方法

问题原因:未配置 Android 下的 junit 测试框架的配置信息

解决方案:

方法1:按照 junit 测试框架的配置,编辑 AndroidManifest.xml 文件--->此法不方便,要求记住如何配置

方法2:

1)右键---> Android Test Project---> 测试项目名称(随意写)---> next---> 选择要测试的项目---> finish

2)打开测试项目的 AndroidManifest.xml 文件和要测试的项目的 AndroidManifest.xml 文件,将前者中的

标签、 标签及其内容拷贝到后者中(按前者的样子粘贴即可)

6. Caused by: libcore.io.ErrnoException: open failed: EROFS (Read-only file system)

发生场景:运行 Android 程序下载文件到内存卡

问题原因:文件写入路径出错

解决方案:

1) 查询自己的文件写入路径是否正确?

2) 查看清单文件,看是否赋予了android.permission.WRITE_EXTERNAL_STORAGE 权限

7. 创建目录失败

发生场景:Android 下创建文件目录

问题原因:加入了 isDirectory 的判断代码,如下:

/**

* 若文件夹不存在,则创建文件夹

* @param dirpath目录路径

* @return flag目录创建是否成功的标志

*/

public static boolean createDir(String dirpath){

boolean flag = false;

File file = new File(dirpath);

System.out.println("file:" + file);

if(file.isDirectory()){// 判断该路径是否为一个目录

if(!file.exists()){// 判断该目录是否存在

file.mkdirs();

System.out.println("done...");

flag = true;

}

} else {

System.out.println("不是目录路径");

}

return flag;

}

解决方案:

将原代码改写:去掉 isDirectory() 的判断[注:发现在 Android 下使用 isDirectory 函数,传递进来的合法路径,最终都会给出 false,即不是一个目录路径]

public static boolean createDir(String dirpath){

boolean flag = false;

File file = new File(dirpath);

if(!file.exists()){// 判断该目录是否存在

file.mkdirs();

System.out.println("done...");

flag = true;

}

return flag;

}

8. E/AndroidRuntime(13254): java.lang.RuntimeException: setAudioSource failed.

发生场景:实现来电监听录音

问题原因:录音需要添加用户权限

解决方案:添加权限:

9. E/AndroidRuntime(24790): java.lang.IllegalStateException

发生场景:实现来电监听录音

问题原因:音频文件报错路径有误,未存在的文件路径

出错代码:

public class PhoneListenerService extends Service {

private final String SAVE_PATH = Environment.getExternalStorageDirectory().getPath() + "/PhoneListener/";

...

private MediaRecorder prepareRecorder() {

...

recorder.setOutputFile(SAVE_PATH + time + ".3gp");

...

}

}

解决方案:

因文件夹 PhoneListener 本身不存在,故而将 SAVE_PATH 改为 Environment.getExternalStorageDirectory().getPath() + 存在的文件名 即可

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值