Eclipse提示:
498.error:Error parsing XML:unbound prefix
使用第三方View的时候需要引入相应的xml命名空间xmlns。否则就会报这个错。
499.Problem: ‘Android SDK Content Loader’ has encountered a problem. parseSdkContent
failed
Solution:
Today i just have started development under the Eclipse Indigo environment and while setting Android SDK preferences, i suddently got the following error:
‘Android SDK Content Loader’ has encountered a problem.
parseSdkContent failed
java.lang.NullPointerException.
I have tried to do google around half an hour to know the reason behind this and solve the same, let me share a possible(i am not sure this works for you but it worked for me) solution which i got during the searching:
The issue is in the your-avd-name.ini that is located at ….android on your Windows machine (if you’re Windows user). When any error occurs during the avd.ini parser, the Google ADT plugin tries to access a map that is null. The workaround is to delete
the offending .ini file and recreate your avd(s).
删除电脑中C:\Users\用户名\.android\avd目录下的.ini配置文件,然后重启Eclipse就可以了。至于造成这个问题的原因是安装了AndroidStudio后。其他原因造成的不一定管用。
500.overlaps the location of another project: 'xxxx'
new -> android project -> create project from exist source
出现如下错误信息:
Invalid project description
------>detail: ->>> xxxx(project path) overlaps the location of another project: 'xxxx'
最后发现时我把源码把放到了workspace目录下了的原因导致的。
eclipse插件在创建项目的时候需要在workspace目录下创建一个同名的目录。
但发现workspace目录下已存在对应的目录时,就会报上面的处错误信息了。
解决办法很简单,就是将源码包移到非workspace目录下
Android提示
28.android FAILED Binder Transaction 问题的原因
选择图片,在onActivityforResult()传递到预览页面,图片太大,报了这个异常。
今天在做一个widget的时候需要填充一个ImageView,图片来自与网络。 发现都会出现FAILED Binder
Transaction这个问题。 通过google得知,原来图片的size不能超过40k。 Activity中ImageView是不会出现这个问题, 但是Widget使用的是remoteViews。 Intent传输的bytes不能超过40k。优其在Intent
中传递图片时,要限制图片小 40K.\
参考:http://blog.csdn.net/glony/article/details/7596430
27.java.io.IOException: open failed: ENOENT 没有这样的文件或目录
03-15 14:30:50.912: W/System.err(25808): java.io.IOException: open failed: ENOENT (No such file or directory)
03-15 14:30:50.912: W/System.err(25808): at java.io.File.createNewFile(File.java:948)
在android4.0的手机上直接创建某个文件的路径一直报这个错:open failed: ENOENT (No such file or directory)
在网上查了很多资料,没找到解决方案,尝试了多次终于找到解决办法
如果在FileOutputStream创建一个流文件路径时或者是对一个File文件路径直接操作时,
可先创建文件的路径,然后在创建文件名就不会在报该错误
以下是解决方案:
public static File getFilePath(String filePath,
String fileName) {
File file = null;
makeRootDirectory(filePath);
try {
file = new File(filePath + fileName);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return file;
}
public static void makeRootDirectory(String filePath) {
File file = null;
try {
file = new File(filePath);
if (!file.exists()) {
file.mkdir();
}
} catch (Exception e) {
}
}
参考:http://www.cnblogs.com/xytyes/archive/2012/08/04/2622693.html
26.Adbconnection Error:您的主机中的软件中止了一个已建立的连接
控制台DDMS不停的提示这个错误,产生这个错误的情景是:
手机系统是Android4.0.3,windows7 64bit,Eclipse打开了两个或两个以上,adb是32bit的。每次运行都会不停提示这个错误。在系统为2.3.4的Android系统运行没有这个错误现象。
解决办法(感谢作者):
问题出现的原因:这是ddms调用adb引发的.经过一番搜索,发现这是windows环境下,
adb的一个限制,也可以说是bug.当手机上同时运行的进程数大于64时,就会引发adb奔溃.更深层次的原因,就是windows
API的WaitForMultipleObjects所支持的最大句柄数是MAXIMUM_WAIT_OBJECTS,即64.
解决问题的办法:http://code.google.com/p/android/issues/detail?id=12141下载相应的adb.exe文件(下载处在下面的附件标志,不是页面上面的
downLoad ),用它替换掉你机器上的sdk的platform/tools目录下面的adb.exe。这样就可以完美解决问题。
25.export aborted because fatal lint errors were found
作者:Eping发布时间:May 14, 2012分类:Android
Eclipse打包时出现export aborted because fatal lint errors were found
参照http://stackoverflow.com/questions/8590908/android-export-aborted-because-fatal-error-were-founds
解决办法:
Project -> properties, find Android Lint Preferences, in top to right click configure workspace settings... -> unclick "Run full error check when exporting app", apply done.
ctrl + l delete line
24.jpush的一个java.lang.UnsatisfiedLinkError: Couldn't load jpush: findLibrary returned null
不知这是什么原因?问题出在JPushInterface.init(this);
问题已解决,原因是libs目录下多了一个armeabi-v7a文件夹,而这个文件夹下面没有libjpush.so,
我复制进去一份,运行。OK没问题了。
23.java.lang.RuntimeException: Canvas: trying to use a recycled bitmapandroid.graphics.Bitmap@2b004ab8
E/AndroidRuntime(14016):
java.lang.RuntimeException:
Canvas: trying to use a recycled bitmap
android.graphics.Bitmap@2b004ab8
回收时机不当造成的错误
22.java.net.ConnectException: 42.121.237.116/42.121.237.116:80 -
Network is unreachable
无法访问
21.java.lang.IllegalArgumentException: bitmap size exceeds 32bits
E/AndroidRuntime(4113): Caused by:
Matrix matrix = new Matrix();
// matrix.setRotate(degree,width,height);
// matrix.setRotate(degree);
matrix.postScale(newWidth, newHeight);
newbmp = Bitmap.createBitmap(bmp, 0, 0, width, height, matrix, true);
使用Matrix缩小图片时产生错误。postScale()方法里面的参数是新宽(高)和旧宽(高)的比值。而不是新的宽高。
bitmap所占内存的大小取决于尺寸和每个像素占的字节数。像素有几个参数在Bitmap.Config类里面有四个常量即是。不同的常量会占用不同数量的字节。
20.上传图片产生java.net.SocketException: Broken pipe
上传图片出错
19. java.lang.OutOfMemoryError: bitmap size exceeds VM budget
1280000-byte external allocation too large for this process.
VM won't let us allocate 1280000 bytes
E/dalvikvm-heap(10866): 1440000-byte external allocation too large for this process.
E/GraphicsJNI(10866): VM won't let us allocate 1440000 bytes
E/AndroidRuntime(10866): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
编写一个应用程序用来从网络加载图片并显示,结果图片数量一多,出了这么个错误。
7990272bytes计算了一下这个值发现是7M多,难怪崩溃,原以为700多kb。发现手机拍摄的照片的长宽分别是3000多和2000多,在没改变尺寸的时候很容易出现这样的崩溃提示。
1.Bitmap.Options进行了图片的压缩,解决了图片过大容易OutofMemory的错误
2.在适当的时机对bitmap进行回收
18.MainActivity has leaked window
view@40602988 that was originally added here
添加PopupWindow显示后,按返回键出了这个错。override onkeydown方法或许解决问题。
17.android.content.res.Resources$NotFoundException
使用PopupWindow在用LayoutInflater inflate()方法时候,第一个参数传递一个XML resource,传递了一个LinearLayout的id出了这个错无。改成XML文件名就ok了。
16.android.view.WindowManager$BadTokenException: Unable to add window
I'm having trouble getting an alert dialog to show inside of a Tab Activity. My app will force close every time I try and get the alert dialog to show
AlertDialog在TabActivity中显示出的错误。
解决方法:
用AlertDialog.Builder builder = new AlertDialog.Builder(this.getParent()); 代替 AlertDialog.Builder builder = new AlertDialog.Builder(this);
详情请参考下面链接。
15.audioflinger could not create track status -22
出现这个问题的原因是SoundPool对象调用play方法的时候最后一个参数的值取的太大了。合理范围是0.5到2
14.SoundPool的sample 1 not READY
因为未完成加载就播放了,应该调用
sp.setOnLoadCompleteListener(new OnLoadCompleteListener(){ @Override public void onLoadComplete(SoundPool arg0, int arg1, int arg2) { sp.play(spload, 1, 1, 1, 1, 1); }});
13.AudioPolicyManagerBase error unknown stream type
音频录制播放程序正常运行,但是logcat出现了这个提示,从网上搜了一下,有人说set the audio stream as STREAM_MUSIC的原因,但也说出个太多所以然感觉。参考:http://stackoverflow.com/questions/6895513/audiopolicymanagerbase-error
12.no selected voice recognition service
手机语音转文字的时候,给了一个这种提示,程序没有正确运行。不知道什么原因
11.Error creating AudioRecord instance: initialization check failed.
录音程序一开始就崩溃了。
10.java.lang.IllegalStateException: startRecording() called on an uninitialized AudioRecord
E/AudioRecord(2806): AudioFlinger could not create record track, status: -1
E/AudioRecord-JNI(2806): Error creating AudioRecord instance: initialization check failed.
E/AudioRecord-Java(2806): [ android.media.AudioRecord ] Error code -20 when initializing native AudioRecord object.
原因很简单,没有添加权限<uses-permission android:name="android.permission.RECORD_AUDIO"/>
9.Caused by: android.content.ReceiverCallNotAllowedException: IntentReceiver components are not allowed to bind to services
学习了TTS(Text To Speech)以后想在BroadcastReceiver里面使用,当收到一个
广播以后,用声音给出提示,多炫的功能啊。但是实际测试的时候报了这个错。有待研究。
8.Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
在Activity中继承了ListActivity本以为不需要xml布局文件了,但是视频教程上还是用了xml布局,由于我的ListView id
不是 android:id="@id/android:list"所以报了这个错误。
7.close() was never explicitly called on database
onDestroy的时候调用close()方法
6.No resource identifier found for attribute 'parentActivityName' in package 'android'
android:parentActivityName appears first in Android 4.1 (API level 16). You need to have the latest 4.1 SDK to compile this.
5. ellipsis failed line number does not match 2 1
TextView中设置了android:singleLine = "true" android:ellipsize = "end"
在settext的时候出现了上述的错误,把android:singleLine = "true"删除掉,就没有这个错误了。
错误原因:文字内容中有空格。不过没有尝试在没有空格的情况,是否没有这个错误!
解决办法:
为了只显示一行可以用这两个属性android:inputType="text" android:maxLines="1"。不过没有那三个省略号了
4.Android文件下载完成后出现java.io.IOException: unexpected end of stream
文件下载成功了,可以正常使用但是却出现了这个异常,不知道怎么回事?
代码来源于stackoverflow.com
<strong>public void run() { try { URL downurl = new URL(url); URLConnection connection = downurl.openConnection(); connection.connect(); int fileLength = connection.getContentLength();//Returns the value of the content-length header field InputStream ins = new BufferedInputStream(downurl.openStream()); OutputStream ous = new FileOutputStream("/sdcard/adown.wma"); byte[] buf = new byte[1024];long total = 0;int count; while((count = ins.read(buf)) != -1){// logcat提示问题出现在这里 total += count; int p = (int)(total * 100 / fileLength); handler.sendEmptyMessage(p); ous.write(buf, 0, count); } ous.flush();ous.close();ins.close(); }</strong>
That exception is thrown by FixedLengthInputStream when the expected number of bytes (usually set in the content-length header of the response) is larger than the actual data in the response. Check that the content-length header is correct. (If you're supplying
your own value for the content length, make sure it is correct.)
错误原因:固定长度输入流当期望的字节数大于实际响应返回的字节数,就会抛出这个异常。但是在循环读取的时候也有读取字节数小于1024的情况,为什么这时候不异常,读到最后就异常呢?另外在代码中无需使用BufferInputStream,因为下面已经自定义了一个1024字节的缓存,这样就双缓存了,多此一举。ins = downurl.openStream();即可。
3.No resource identifier found for attribute 'xlargeScreens' in package 'android'
错误详情:
错误原因:错误出现在AndroidManifest.xml文件中supports-screens标记中,原因是xlargeScreens属性在API9(Android2.3)中才支持
解决办法:将Android2.2 remove,添加Android2.3即可解决
2.View not attached to window manager
错误详情:
01-28 16:36:40.236: E/AndroidRuntime(2763): java.lang.IllegalArgumentException: View not attached to window manager
错误原因:这个错误是在AsyncTask中的onPostExecute()方法中ProgressDialog.dismiss()的时候发生的。
解决办法:来自stackoverflow.com感谢贡献者
@Override
protected void onPostExecute(MyResult result) {
try {
dialog.dismiss();
dialog = null;
} catch (Exception e) {
// nothing
}
finish();
}
1.Exported servicedoes
not require permission警告
很久没写过应用了,今天写一个Service时,在manifest文件的<service>标签发现了这个警告
- <service
- android:name="SendService">
- <intent-filter>
- <action android:name="com.oem.OEMSendService.SENDMAIL" />
- </intent-filter>
- </service>
查了下api,终于发现一些端倪
原因:这是一个可以被外部访问的service,需要使用权限来限制外部访问
解决方法:
1.添加
android:exported="false
"
这种方法是限制外部访问,自然不需要权限了
2.声明权限
先在<manifest>标签下加入
<permission android:protectionLevel="normal" android:name="oem.permission.SENDMAIL"></permission>
然后在<service>标签下
android:permission="oem.permission.SENDMAIL"