Android开发_错误集锦------收录中


1.MapJarInstallation error: INSTALL_FAILED_MISSING_SHARED_LIBRARY

ERROR/PackageManager(556): Package irdc.ex10_02 requires unavailable shared library com.google.android.maps; ignoring!

 

在把apk文件手动安装到模拟器的时候,抛出安装异常INSTALL_FAILED_MISSING_SHARED_LIBRARY,经查发现是模拟器对于的API不匹配,设置成合适的API后正常。

源文档 <http://archive.cnblogs.com/a/1974750/>

 

新建一个模拟器,然后在Target里面选择Google APIs(Google Inc.) -API Level 7 这样,调试的时候用这个模拟器就好了

 



2.WTK错误:java.lang.UnsatisfiedLinkError: C:/WTK2.5.2_01/bin/sublime.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform

问题所在:

主要是在64位的系统下安装的虚拟机是64位的,而WTKsublime.dll不能在64位的平台下加载64位的虚拟机,只能加载32位的。由于WTK在安装的时候加载的64虚拟机的地址,它找到的是64位的虚拟机,所以它提示不能加载32位的虚拟机(在目录下没有32的虚拟机)。

解决方案:

1.重新下载一个32位的虚拟机,例如:jre-6u23-windows-i586.exe

2.安装虚拟机,目录所在位置——例如:C:/Java/jre-6u23-windows-i586

2.卸载WTK

3.安装WTK,虚拟机地址,选择2步骤,的目录地址

4.重启eclipse,找到设备管理器,更新模拟器位置。

5.OK

源文档 <http://blog.csdn.net/gumanren/article/details/6455991>

 



3.ADBADB server didn't ACK

errors:

* daemon not running. starting it now *

ADB server didn't ACK

* failed to start daemon *

解决办法:

(1)查看任务管理器,关闭所有adb.exe

(2)重启eclipse即可

源文档 <http://www.cmd100.com/bbs/forum.php?mod=viewthread&tid=3915>

 



4.TFS调试运行Eclipse插件遇到的问题:The editor class could not be instantiated.

在开发Eclipse插件,调试运行插件时大家可能会遇到这样的问题:

"Unable to create this part due to an internal error. Reason for the failure: The editor class could not be instantiated. This usually indicates that the editor's class name was mistyped in plugin.xml."

 

我在开发是出现这种问题主要是因为重新建立了一个新的插件项目,项目名称与原来删除的项目名称相同导致。

 

具体解决办法如下:

1、找到运行插件项目的workspace(注意:不是你开发插件运行的Eclipseworkspace),一般目录名称为“runtime-EclipseApplication”。

2、找到后进入目录“.metadata\.plugins”察看是否有你要运行的插件的名称,如“XXX”,把这个目录删除即可,简单方法是把“.metadata\.plugins”中的全部目录删除。

3、再执行插件项目,OK了:)

源文档 <http://www.blogjava.net/hengheng123456789/articles/75004.html>

Failed】以上方法未成功解决。

 


5.ADB


任务器结束adb.exe后,重启adb.exe

 



6.【】

Description        Resource        Path        Location        Type

Unparsed aapt error(s)! Check the console for output.

 

 

 


7.TFS

Could not open the editor: The editor class could not be instantiated. This usually indicates a missing no-arg constructor or that the editor's class name was mistyped in plugin.xml.


待解决。

具体解决办法如下:

1、找到运行插件项目的workspace(注意:不是你开发插件运行的Eclipseworkspace),一般目录名称为“runtime-EclipseApplication”。

2、找到后进入目录“.metadata\.plugins”察看是否有你要运行的插件的名称,如“XXX”,把这个目录删除即可,简单方法是把“.metadata\.plugins”中的全部目录删除。

3、再执行插件项目,OK了:)

源文档 <http://www.blogjava.net/hengheng123456789/articles/75004.html>

 



8.RunTime

No command output when running: 'am start -n com.surekam/com.surekam.MainActivity -a android.intent.action.MAIN -c android.intent.category.LAUNCHER' on device emulator-5554

设置intentFilter中<category android:name="android.intent.category.LAUNCHER"/>就是要求软件apk在安装时候在控制台中有应用程序的安装图标(理解为桌面图标)

源文档 <http://topic.csdn.net/u/20110227/00/2f326e9c-ea02-42cd-a118-305f7a725eb5.html>

 



9.AVD路径问题】修改默认AVD的路径---ERROR: unknown virtual device name

Documents and Settings\用户名\.android\avd下边,这个路径里不能有中文。
解决方法

1
 最简单的,创建个英文名的用户,在新的用户环境下玩
2
手动添加一个系统环境变量值,这里我们可以对着“我的电脑”图标单击鼠标右键,在弹出的菜单中选择“属性”,切换到“高级”选项卡,单击“环境变量”按钮,在弹出的对话框新建一个环境变量,比如名为ANDROID_SDK_HOME (不可修改为其他) ,值为D:\android_sdk (假设sdk我们在d盘的根目录名为android_sdk)。接下来重新启动Eclipse,我们通过单击Windows菜单,依次进入 preferneces => Android => Bulid 可以看到 Default debug keystore: D:\android_sdk\.android\debug.keystore (其中.android\ADT自动创建的,以前这项可能为C:\Documents and Settings\中文\.android\debug.keystore),当然通过设置下面的custom debug keystore来设置可以免除添加环境变量的步骤。
然后重建avd。运行程序,没问题了

源文档 <http://zhidao.baidu.com/question/248076502.html>

 



10.【项目不是一个工程】添加以下文本中的三个文件后导入即可Eclipse

<<非工程项目导入解决方案.txt>>

http://blog.csdn.net/wujxiaoz/article/details/7425142

 


11.Cygwinset NDK_PROJECT_PATH=f:/WDSP/MyFFMpegM--路径映射问题:


/cygdrive/e/NDK/android-ndk-r6b-windows/build/core/setup-toolchain.mk:109: *** 目标模式不含有“%”。 停止。

将:f:改为/cygdrive/f

 


11.NDK-GDB

ERROR: Non-debuggable application installed on the target device.

 


12.DDMS】小米系统--File Explorer无法显示文件目录

在系统/system/bin里面可以发现没有ls文件,所以不能DDMS中调用file explorer

解决办法:(未解决)

1。在Eclipse里面开模拟器,通过模拟器的DDMS->file explorer找到/system/bin,导出toolbox替换真机相同目录下文件(可能需要ROOT explorer等软件)

2。在真机/system/bin下做一个名为ls的连接文件指向toolbox

      linux下可以直接用Link命令

      手机端开root explorer,/system/bin下找到同样一个指向toolbox的连接文件,如cat,拷贝一份,重命名为ls即可!

源文档 <http://www.miui.com/forum-viewthread-tid-118128-highlight.html>

 


13.Run As】程序运行程序时,manifest设置主Activity时无效。

错误:No activity specified! Getting the launcher activity.


解决方案:应该选中Launch Default Activity (默认选择)或选择Launch时后边的下拉列表应选择Activity(不要为空),上图为错误的配置。

 


14.JDKJDK升级1.7时,项目报错误:

错误:Android requires compiler compliance  level 5.0 or 6.0.Found ''1.7 instead.Please use Android Tools >Fix Project Properties.

解决方案:

Project Properties -> java Compiler -> Enable project specific settings ->再选择 Compiler Compliance Leave(选择任意一个值) -> OK

源文档 <http://www.eoeandroid.com/thread-105431-1-1.html>

 


15.【模拟器】SDL_app:emulator-arm.exe(在XP 32位上报的错误)


解决方案:

模拟器的名称应在5个字符及以上。(如:xxxxx

 


16 AVD start problem


Failed to allocate memory: 8

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

I meet it now, the problem code is this... So we need change the RAM of AVD!  the first I give it 1024 MB ,  change to 512 MB is OK!!!!

Original text is    http://stackoverflow.com/questions/7222906/failed-to-allocate-memory-8,

You can see it, I hope it can help you !



17     Project has no default.properties file! 

solve :  Restart eclipse ! It ok!....

original :   http://www.eoeandroid.com/thread-22268-1-1.html




18 .报错: 
BUILD FAILED 
D:\workspace\ganji\build.xml:144: The following error occurred while executing this line: 
D:\workspace\ganji\build.xml:271: Unable to delete file D:\workspace\ganji\tmp\proguard\tmp.jar 
解决: 
已经开了一个模拟器了,无法重新编译,必须关闭一个。用于ant 



19 .报错: 
The connection to adb is down, and a severe error has occured. 
这个问题谁能解决啊 
解决: 
cmd跳到sdk tools文件路径下 
adb kill-server 
然后再adb start-server 

solve

Try below steps:

  1. Close the Eclipse if running
  2. Go to the Android SDK platform-tools directory in Command Prompt
  3. type adb kill-server
  4. then type adb start-server
  5. No error message is thrown while starting ADB server, then adb is started successfully.
  6. Now you can start Eclipse again.



20.报错: 
The connection to adb is down, and a severe error has occured. 
[2010-03-11 09:36:56 - HelloOPone] You must restart adb and Eclipse. 
[2010-03-11 09:36:56 - HelloOPone] Please ensure that adb is correctly located at 'D:\OPhoneSDK_1.5 
\platform-tools\adb.exe' and can be executed. 
解决: 
方法1.cmd中adb kill-server,然后adb -startserver 
方法2.方法1不管用,那么在任务管理器中杀死adb.exe,然后重启Eclipse。 
方法3.方法1和2都不管用,那么查看最后一句报错中:platform-tools中是否有adb.exe(我的错误就是在相关路径下面没有platform-tools文件夹 
,所以我选择新建一个文件夹,并且把tools中的文件全部复制到platform-tools中) 



21.启动和关掉 adb服务器 

当你启动 Android服务器时,adb服务器也就会一起启动。当你无法确定 adb服务器是否已启动?可以用“adb start-server”命令来启动 adb服务器,如果已启动就不做任何事,尚未启动就会直接启动 adb服务器。若你不想继续进行调试监控,则可以用“ adb kill-server”命令来关掉 adb服务器。 

E:\Android\android-sdk-windows\platform-tools>adb start-server

E:\Android\android-sdk-windows\platform-tools>adb kill-server

E:\Android\android-sdk-windows\platform-tools>adb devices

daemon not running. starting it now on port 5037 *

could not read ok from ADB Server, error 109

failed to start daemon *

error: cannot connect to daemon

E:\Android\android-sdk-windows\platform-tools>adb devices

daemon not running. starting it now on port 5037 *

daemon started successfully *

List of devices attached

2CBE000400000001        device

 

android adb shell:unknown host service

我们在Windows DOS窗口中输入adb shell后,会出现如下错误: adb server is out of date.  killing... ADB serverdidn't ACK * failed to start daemon * error: unknown host service   ,出现这问题是因为你的电脑上安装了豌豆夹造成的,只需打开“任务管理器”,找到'wandoujia_helper.exe',把这个进行终止掉就可以,


 

 

 

************************************************************************************************************************

于Unable to instantiate activity ComponentInfo错误解决方案

     

今天调试程序的时候报了

 

 java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.android/activity.MainTabActivity}:

 java.lang.ClassNotFoundException:

                   ativity.MainTabActivity in loader alvik.system.PathClassLoader@444a88b0

 

这个异常,网上搜一下,说是AndroidManifest.xml 配置 activity 时路径搞错了。

于是我查看了一下,关键代码如下

<activity android:name="activity.MainTabActivity 
          
                  android:label="@string/app_name">
                  
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            
</activity>

更改 android:name="activity.MainTabActivity " 为 android:name=".activity.MainTabActivity "

更改以上路径就解决此问题了

 

这里也可以改为完整路径(指当前activity所在的包下的路径) android:name="com.android.activity.MainTabActivity 

 

 


android BitmapFactory的OutOfMemoryError: bitmap size exceeds VM budget解决方案

 

使用android提供的BitmapFactory解码一张图片时,有时会遇到该错误,即:java.lang.OutOfMemoryError: bitmap size exceeds VM budget。这往往是由于图片过大造成的。要想正常使用,一种方式是分配更少的内存空间来存储,即在载入图片的时候以牺牲图片质量为代价,将图片进行放缩,这也是不少人现在为避免以上的OOM所采用的解决方法。但是,这种方法是得不偿失的,当我们使用图片作为缩略图查看时候倒是没有说什么,但是,当需要提供图片质量的时候,该怎么办呢?java.lang.OutOfMemoryError: bitmap size exceeds VM budget着实让不少人欲哭无泪呀!前几天刚好有个需求需要载入SD卡上面的图片。

首先是使用

?
Bitmap bmp = BitmapFactory.decodeFile(pePicFile.getAbsolutePath() + "/" +info.getImage()); 

上面参数是我将要读取的图片文件及路径,当文件较小时,程序能够正常运行,但是当我选择一张大图时,程序立刻蹦出了java.lang.OutOfMemoryError: bitmap size exceeds VM budget的OOM错误!

在android设备上(where you have only 16MB memory available),如果使用BitmapFactory解码一个较大文件,很大的情况下会出现上述情况。那么,怎么解决?!

先说之前提到过的一种方法:即将载入的图片缩小,这种方式以牺牲图片的质量为代价。在BitmapFactory中有一个内部类BitmapFactory.Options,其中当options.inSampleSize值>1时,根据文档:

If set to a value > 1, requests the decoder to subsample the original image, returning a smaller image to save memory. (1 -> decodes full size; 2 -> decodes 1/4th size; 4 -> decode 1/16th size). Because you rarely need to show and have full size bitmap images on your phone. For manipulations smaller sizes are usually enough.

也就是说,options.inSampleSize是以2的指数的倒数被进行放缩。这样,我们可以依靠inSampleSize的值的设定将图片放缩载入,这样一般情况也就不会出现上述的OOM问题了。现在问题是怎么确定inSampleSize的值?每张图片的放缩大小的比例应该是不一样的!这样的话就要运行时动态确定。在BitmapFactory.Options中提供了另一个成员inJustDecodeBounds。

?
1
2
3
BitmapFactory.Options opts = new  BitmapFactory.Options();
opts.inJustDecodeBounds = true ;
Bitmap bitmap = BitmapFactory.decodeFile(imageFile, opts);

设置inJustDecodeBounds为true后,decodeFile并不分配空间,但可计算出原始图片的长度和宽度,即opts.width和opts.height。有了这两个参数,再通过一定的算法,即可得到一个恰当的inSampleSize。Android提供了一种动态计算的方法。如下:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
public  static  int  computeSampleSize(BitmapFactory.Options options,
         int  minSideLength, int  maxNumOfPixels) {
     int  initialSize = computeInitialSampleSize(options, minSideLength,
             maxNumOfPixels);
 
     int  roundedSize;
     if  (initialSize <= 8 ) {
         roundedSize = 1 ;
         while  (roundedSize < initialSize) {
             roundedSize <<= 1 ;
         }
     } else  {
         roundedSize = (initialSize + 7 ) / 8  * 8 ;
     }
 
     return  roundedSize;
}
 
private  static  int  computeInitialSampleSize(BitmapFactory.Options options,
         int  minSideLength, int  maxNumOfPixels) {
     double  w = options.outWidth;
     double  h = options.outHeight;
 
     int  lowerBound = (maxNumOfPixels == - 1 ) ? 1  :
             ( int ) Math.ceil(Math.sqrt(w * h / maxNumOfPixels));
     int  upperBound = (minSideLength == - 1 ) ? 128  :
             ( int ) Math.min(Math.floor(w / minSideLength),
             Math.floor(h / minSideLength));
 
     if  (upperBound < lowerBound) {
         return  lowerBound;
     }
 
     if  ((maxNumOfPixels == - 1 ) &&
             (minSideLength == - 1 )) {
         return  1 ;
     } else  if  (minSideLength == - 1 ) {
         return  lowerBound;
     } else  {
         return  upperBound;
     }
}  

以上参考一下,我们只需要使用此函数就行了:

?
BitmapFactory.Options opts = new  BitmapFactory.Options();
opts.inJustDecodeBounds = true ;
BitmapFactory.decodeFile(imageFile, opts);
             
opts.inSampleSize = computeSampleSize(opts, - 1 , 128 * 128 );
//这里一定要将其设置回false,因为之前我们将其设置成了true     
opts.inJustDecodeBounds = false ;
try  {
     Bitmap bmp = BitmapFactory.decodeFile(imageFile, opts);
     imageView.setImageBitmap(bmp);
     } catch  (OutOfMemoryError err) {
     }

这样,在BitmapFactory.decodeFile执行处,也就不会报出上面的OOM Error了。完美解决?如前面提到的,这种方式在一定程度上是以牺牲图片质量为代价的。如何才能更加优化的实现需求?

当在android设备中载入较大图片资源时,可以创建一些临时空间,将载入的资源载入到临时空间中。

?
1
2
BitmapFactory.Options bfOptions= new  BitmapFactory.Options();
bfOptions.inTempStorage= new  byte [ 12  * 1024 ];

以上创建了一个12kb的临时空间。然后使用Bitmap bitmapImage = BitmapFactory.decodeFile(path,bfOptions);但是我在程序中却还是出现以上问题!以下使用BitmapFactory.decodeFileDescriptor解决了以上问题:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
BitmapFactory.Options bfOptions= new  BitmapFactory.Options();
              bfOptions.inDither= false ;                   
              bfOptions.inPurgeable= true ;             
              bfOptions.inTempStorage= new  byte [ 12  * 1024 ];
             // bfOptions.inJustDecodeBounds = true;
              File file = new  File(pePicFile.getAbsolutePath() + "/" +info.getImage());
              FileInputStream fs= null ;
              try  {
                 fs = new  FileInputStream(file);
             } catch  (FileNotFoundException e) {
                 e.printStackTrace();
             }
              Bitmap bmp = null ;
              if (fs != null )
                 try  {
                     bmp = BitmapFactory.decodeFileDescriptor(fs.getFD(), null , bfOptions);
                 } catch  (IOException e) {
                     e.printStackTrace();
                 } finally {
                     if (fs!= null ) {
                         try  {
                             fs.close();
                         } catch  (IOException e) {
                             e.printStackTrace();
                         }
                     }
                 }

当然要将取得图片进行放缩显示等处理也可以在以上得到的bmp进行。

PS:请图片处理后进行内存回收 bmp.recycle();这样将图片占有的内存资源释放。


 

 

 


未完待续。。。。。




  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值