android打包和安装过程问题汇总

1、export aborted because fatal lint errors were found

Eclipse打包时出现export aborted because fatal lint errors were found
解决办法:
Project -> properties, find Android Lint Preferences, in top to right click configure workspace settings... -> unclick "Run full error check when exporting app", apply done.

工程项目右键 -> Android Tools -> Clean Lint Markers

2、报错Conversion to Dalvik format failed: Unable to execute dex

问题发生概述:
       程序编译正常,在用Eclipse调试执行时,报错Unable to execute dex: Multiple dex files define,因为以前也没有遇到这类错误,首先便尝试万能纠错发,如下方法一,也是上网搜索众多解决方案之一,尝试后未果,便按照搜索方案,逐一尝试,都未能解决,最后盯着工程突然发现问题。具体解决方案如下:

方法一:
       Eclipse->Project->去掉Build Automatically->Clear ->Build Project->Build Automatically,关闭Eclipse,再打开(我的问题不是出在这)


方法二:           
      更新ADT插件,删除workspace目录下的.metadata目录,(这个解决方案没有尝试,因为在开发过程中,我只是更换了一个jar包而出现的错误,而且开发环境不能连网络,不方便尝试)


方法三:
      在你的项目下某个文件夹中有一个后缀为*.APK的文件,删掉,重启Eclipse即可。(尝试未果)


方法四:
      原因是有重复的。jar被引用,可以查看你的build path,尤其是Android Dependencies一定有重复引入的.jar包,解决的方法是在libs删除重复的jar即可。 (我找了半天,也没有发现重复引用的jar包,不过还是得感谢这位同学,我最终能解决问题也是受到这个方案的启发,贴上博客连接http://blog.sina.com.cn/s/blog_4b9b6ad001016uuk.html


方法五:(成功解决方法)
      在项目中,有一个类的包名和引用的jar包中的类和包名一致,我用的是jar包中的类,所以工程中的这个类就是重复引用的,删除工程中重复引用的类后,成功打包启动。希望各位同学注意这个小问题。

3、android打包好的apk文件在安装的时候出现""for security,your phone is set to block installation of applications not obtained from Android Market."

在Settings-applications里面Unknow sources后面打勾就ok了。

4、安装错误:

Installation error: INSTALL_FAILED_UPDATE_INCOMPATIBLE
Installation error: INSTALL_FAILED_SHARED_USER_INCOMPATIBLE

INSTALL_FAILED_UPDATE_INCOMPATIBLE
1、由于卸载没有完全,可以使用设置中卸载相应应用,或者adb uninstall com.android.***

通过设置中卸载:

这很可能是因为你在以前uninstall应用的时候,没有做彻底,只是简单的rm/data/app/下面的apk文件了一个补救的办法如下
启动模拟器,然后进入菜单
settings->applications->mange
applications->select the application->select "unistall".

这样就能彻底删除了,然后再重新安装这个apk就没问题了
另外一个办法就是将 /data/system/packages.xml 中该应用相应的信息删掉,重启模拟器再安装即可,因为adb install后,会在packages.xml中添加相应的程序信息。

过eclipse编译android源码中,如果编译Settings或者android manifest XML中 shared user id 包含android.uid.shared等系统权限的时候,则会报以下错误。

INSTALL_FAILED_SHARED_USER_INCOMPATIBLE
主要是由于使用了android.uid.shared导致的问题。
解决方案如下
第一个方法简单点,不过需要在Android系统源码的环境下用make来编译:

   1. 修改Android.mk文件,加入LOCAL_CERTIFICATE := platform这一行 
2. 使用mm命令来编译,生成的apk就可以在模拟器中运行了。


第二个方法麻烦点,不过不用开虚拟机跑到源码环境下用make来编译:

1. 使用eclipse编译出apk文件,但是这个apk文件是不能用的。 
2. 查看Android.mk文件,加入LOCAL_CERTIFICATE := 这一行,根据这行的内容,选择相应的签名。
platform----->platform.pk8和platform.x509.pem 
shared  ----->shared.pk8和shared.x509.pem
3. 使用目标系统的platform密钥来重新给apk文件签名。这步比较麻烦, 
首先找到密钥文件,在我的Android源码目录中的位置 
是"build\target\product\security",下面的platform.pk8和platform.x509.pem 
两个文件。 
然后用Android提供的Signapk工具来签名,signapk的源代码是 
在"build\tools\signapk"下, 我编译好之后的路径在out/host/linux-x86/framework下。
用法为"java -jar signapk.jar  platform.x509.pem platform.pk8 input.apk output.apk",
signapk.jar的文件名最好使用绝对路径防止找不到,也可以修改源代码直接使用。

  4.其他的APPS应用也是按照该方法可以正常运行,


不过这样生成的程序只有在原始的Android系统或者是自己编译的系统中才可以用,因为这样的系统才可以拿到platform.pk8和 platform.x509.pem两个文件。要是别家公司做的Android上连安装都安装不了。试试原始的Android中的key来签名,程序在模 拟器上运行OK,不过放到G3上安装直接提示"Package ... has no signatures that match those in shared user android.uid.system",这样也是保护了系统的安全。

最最后还说下,这个android:sharedUserId属性不只可以把apk放到系统进程中,也可以配置多个APK运行在一个进程中,这样可以共享数据,应该会很有用的。

 

安装APK的错误码(PackageManager.java)

 

/** 
 * if the package is already installed. 
 * 程序已经存在 
 */  
public static final int INSTALL_FAILED_ALREADY_EXISTS = -1;  
  
  
/** 
 * if the package archive file is invalid. 
 * 无效的APK 
 */  
public static final int INSTALL_FAILED_INVALID_APK = -2;  
  
  
/** 
 * if the URI passed in is invalid. 
 * 无效的链接 
 */  
public static final int INSTALL_FAILED_INVALID_URI = -3;  
  
  
/** 
 * if the package manager service found that the device  
 *   didn't have enough storage space to install the app. 
 * 没有足够的存储空间 
 */  
public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4;  
  
  
/** 
 * if a package is already installed with the same name. 
 * 已存在同名程序 
 */  
public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5;  
  
  
/** 
 * if the requested shared user does not exist. 
 * 共享用户不存在 
 */  
public static final int INSTALL_FAILED_NO_SHARED_USER = -6;  
  
  
/** 
 * if a previously installed package of the same name has a different signature 
 *   than the new package (and the old package's data was not removed). 
 * 更新不兼容 
 */  
public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7;  
  
  
/** 
 * if the new package is requested a shared user which is already installed  
 *   on the device and does not have matching signature. 
 * 共享用户不兼容 
 */  
public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8;  
  
  
/** 
 * if the new package uses a shared library that is not available. 
 * 共享库已丢失 
 */  
public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9;  
  
  
/** 
 * if the new package uses a shared library that is not available. 
 * 替换时无法删除 
 */  
public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10;  
  
  
/** 
 * if the new package failed while optimizing and validating its dex files, 
 *   either because there was not enough storage or the validation failed. 
 * 空间不足或验证失败 
 */  
public static final int INSTALL_FAILED_DEXOPT = -11;  
  
  
/** 
 * if the new package failed because the current SDK version is older than 
 * that required by the package. 
 * 系统版本过旧 
 */  
public static final int INSTALL_FAILED_OLDER_SDK = -12;  
  
  
/** 
 * if the new package failed because it contains a content provider with the 
 *   same authority as a provider already installed in the system. 
 * 存在同名的内容提供者 
 */  
public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13;  
  
  
/** 
 * if the new package failed because the current SDK version is newer than 
 *   that required by the package. 
 * 系统版本过新 
 */  
public static final int INSTALL_FAILED_NEWER_SDK = -14;  
  
  
/** 
 * if the new package failed because it has specified that it is a test-only 
 *   package and the caller has not supplied the {@link #INSTALL_ALLOW_TEST} 
 *   flag. 
 * 调用者不被允许测试的测试程序 
 */  
public static final int INSTALL_FAILED_TEST_ONLY = -15;  
  
  
/** 
 * if the package being installed contains native code, but none that is 
 *   compatible with the the device's CPU_ABI. 
 * 包含的本机代码不兼容CPU_ABI 
 */  
public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16;  
  
  
/** 
 * if the new package uses a feature that is not available. 
 * 使用了一个无效的特性 
 */  
public static final int INSTALL_FAILED_MISSING_FEATURE = -17;  
  
  
// ------ Errors related to sdcard  
/** 
 * if a secure container mount point couldn't be accessed on external media. 
 * SD卡访问失败 
 */  
public static final int INSTALL_FAILED_CONTAINER_ERROR = -18;  
  
  
/** 
 * if the new package couldn't be installed in the specified install location. 
 * 无效的安装路径 
 */  
public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19;  
  
  
/** 
 * if the new package couldn't be installed in the specified install 
 *   location because the media is not available. 
 * SD卡不可用 
 */  
public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20;  
  
  
/** 
 * if the new package couldn't be installed because the verification timed out. 
 * 验证超时 
 */  
public static final int INSTALL_FAILED_VERIFICATION_TIMEOUT = -21;  
  
  
/** 
 * if the new package couldn't be installed because the verification did not succeed. 
 * 验证失败 
 */  
public static final int INSTALL_FAILED_VERIFICATION_FAILURE = -22;  
  
  
/** 
 * if the package changed from what the calling program expected. 
 * 预期的应用被改变 
 */  
public static final int INSTALL_FAILED_PACKAGE_CHANGED = -23;  
  
  
/** 
 * if the parser was given a path that is not a file, or does not end  
 *   with the expected '.apk' extension. 
 * 解析失败,不是APK 
 */  
public static final int INSTALL_PARSE_FAILED_NOT_APK = -100;  
  
  
/** 
 * if the parser was unable to retrieve the AndroidManifest.xml file. 
 * 解析失败,无法提取Manifest 
 */  
public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101;  
  
  
/** 
 * if the parser encountered an unexpected exception. 
 * 解析失败,无法预期的异常 
 */  
public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102;  
  
  
/** 
 * if the parser did not find any certificates in the .apk. 
 * 解析失败,找不到证书 
 */  
public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103;  
  
  
/** 
 * if the parser found inconsistent certificates on the files in the .apk. 
 * 解析失败,证书不一致 
 */  
public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104;  
  
  
/** 
 * if the parser encountered a CertificateEncodingException in one of the 
 *   files in the .apk. 
 * 解析失败,证书编码异常 
 */  
public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105;  
  
  
/** 
 * if the parser encountered a bad or missing package name in the manifest. 
 * 解析失败,manifest中的包名错误或丢失 
 */  
public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106;  
  
  
/** 
 * if the parser encountered a bad shared user id name in the manifest. 
 * 解析失败,manifest中的共享用户错误 
 */  
public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107;  
  
  
/** 
 * if the parser encountered some structural problem in the manifest. 
 * 解析失败,manifest中出现结构性错误 
 */  
public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108;  
  
  
/** 
 * if the parser did not find any actionable tags (instrumentation or application) 
 *   in the manifest. 
 * 解析失败,manifest中没有actionable tags 
 */  
public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109;  
  
  
/** 
 * if the system failed to install the package because of system issues. 
 * 系统问题导致安装失败 
 */  
public static final int INSTALL_FAILED_INTERNAL_ERROR = -110;  

 

 

 

你可能感兴趣的:(android)