Android警告错误搜集
来源:互联网 发布:剑与魔法翅膀升阶数据 编辑:程序博客网 时间:2024/06/04 18:22
Android Studio提示:
- Open
gradle-wrapper.properties
Change this line:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
with
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
- Go to
build.gradle
(Project: your_app_name) Change this line
classpath 'com.android.tools.build:gradle:XXX'
to this
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
or
classpath 'com.android.tools.build:gradle:1.5.0'
- Don't click
Sync Now
- From menu choose
File -> Invalidate Caches/Restart...
- Choose first option:
Invalidate and Restart
Android Studio would restart. After this, it should work normally
Hope it help
出处:http://stackoverflow.com/questions/34749299/gradle-version-2-2-is-required-current-version-is-2-10
Eclipse提示:
后来发现有一个特殊字符导致的。手写一遍就好了,不能偷懒。
解决办法:
Just for answering my own question to share the findings.
To solve the problem of MediaPlayer error (1,-38) after calling mediaPlayer.start() on Android 2.3 device, just add the following clause after setting up the surface holder.
代码在这:
为surfaceHolder设置一个setType即可解决。
...; surfaceHolder_.addCallback(this); surfaceHolder_.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); mediaPlayer_ = new MediaPlayer(); ...;
For devices equal to or higher than Honeycomb, we don't need to set the surface holder type, the framework will handle that automatically for the attached surface view to the media player, that's why the code works in Android 4.0 but not in 2.3. Hence we can use a condition statement to guard the surface holder setType clause as:
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { surfaceHolder_.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); }
这段时间在用PopupWindow做界面的更多操作菜单,发现一个很奇异的问题;
在创建继承PopupWindow的自定义弹出菜单,在高版本的安卓系统中是没有任何问题,但是在2.x系列的系统中就会奔溃,报错的信息如下:
异常信息:
Exception: null
堆栈信息:
android.widget.PopupWindow.setContentView(PopupWindow.java:384)
android.widget.PopupWindow.<init>(PopupWindow.java:286)
android.widget.PopupWindow.<init>(PopupWindow.java:266)
android.widget.PopupWindow.<init>(PopupWindow.java:223)
outChan.truncate(file.length()-length);
outChan.close();
错误的原因:
往往是因为window还没active的window
解决的办法:
很简单,就是在onAttachedToWindow里面的时候再显示你的popupwindow,而不是在onCreate里面:
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
showPopupWindow();
}
497.open failed: EBUSY (Device or resource busy)
删除文件后马上重建一个同名的文件,结果报如此异常。
But the solution is really easy: Before you delete a Directory or File: rename it!
Code to rename:先重命名再删除,重命名删除失败!
final File to = new File(file.getAbsolutePath() + System.currentTimeMillis());file.renameTo(to);to.delete();
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);
详情请参考下面链接。
http://stackoverflow.com/questions/5690069/android-development-alertdialog-showing-inside-of-tab-activity
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感谢贡献者
@Overrideprotected 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"
- Android警告错误搜集
- Android警告错误搜集
- J2EE开发 警告搜集处理
- Android 中遇到的一些警告 错误
- Android开发:Button属性警告错误
- android studio 没有错误、警告提示怎么办
- 错误搜集专帖
- WinCE定制错误搜集
- java错误搜集
- ios7开发错误搜集
- 编译android源码,报:make警告:检测到时钟错误
- 警告关于Android webservice SqlServer文章作者都是错误的
- android中调用inflate时出现的警告错误处理
- 【Android】INSTALL_PARSE_FAILED_MANIFEST_MALFORMED错误与Not targeting the latest versions警告
- android studio 右边没有错误、警告提示怎么办!???
- ASP.NET错误搜集整理
- Hadoop安装配置错误搜集
- IAR错误、警告
- linux-2.6.26内核中ARM中断实现详解
- Matrix Chain Multiplication(栈的简单应用)
- shell 创建文件夹,并在文件夹中创建空文件
- 考研小结
- 输出流效率测试
- Android警告错误搜集
- PHP学习-----文件操作/上传和下载
- 打造心中的暗黑传奇1
- iOS编译错误
- Android数据存储之SharedPreferences
- Java程序员成长之路
- soj 2302. Queue Implementation Using a Circular Array
- 设计模式之工厂方法模式
- XShell 技巧分享