Android错误引用自定义资源数据类型,造成安装解析产生未知错误

Android 2.3.3 Eclipse Version: 3.7.0 LogCat Console

报错信息:

[2012-02-15 10:24:31 - taobao] ------------------------------ [2012-02-15 10:24:31 - taobao] Android Launch! [2012-02-15 10:24:31 - taobao] adb is running normally. [2012-02-15 10:24:31 - taobao] Performing com.taobao.htc.Start activity launch [2012-02-15 10:24:31 - taobao] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'htc' [2012-02-15 10:24:31 - taobao] Uploading taobao.apk onto device 'emulator-5554' [2012-02-15 10:24:36 - taobao] Installing taobao.apk... [2012-02-15 10:24:39 - taobao] Installation error: INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION [2012-02-15 10:24:39 - taobao] Please check logcat output for more details. [2012-02-15 10:24:39 - taobao] Launch canceled!


发生错误原因分析:

安装解析失败,遇到未知错误。

分析AndroidManifest.xml,android:versionCode引用自定义资源

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.taobao.htc" android:versionCode="@string/app_versionCode" android:versionName="@string/app_versionName">


在strings.xml中也有app_versionCode对应值

Xml代码

<?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_versionCode">360</string>

两部分配置在Eclipse中均未提示错误。

根据在AndroidManifest.xml中直接配置versionCode值的经验,其值应为整数,否则Eclipse报错。

error: Error: String types not allowed (at 'versionCode' with value 'htc'). error: Error: Float types not allowed (at 'versionCode' with value '360.0'). error: Error: Boolean types not allowed (at 'versionCode' with value 'true').


解决办法:

修改xml配置

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.taobao.htc" android:versionCode="@integer/app_versionCode" android:versionName="@string/app_versionName"> <?xml version="1.0" encoding="utf-8"?> <resources> <integer name="app_versionCode">360</integer>

重新运行,正常。

不管是直接配置,还是使用引用资源,android:versionCode的值都只能是整数。

引用资源,一定要使用可用的数据类型。

PS:Eclipse的Problems并不是所有错误都能给出提示。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值