您的位置:首页 > 移动开发 > Android开发

aapt解析的坑,记录一下防止再次掉入

2016-12-05 21:13 281 查看
在将app发布到各大市场上之前我们需要自己在本地用aapt解析一遍上传的apk文件,当然你也可以选择等各大市场将你的apk打回来之后再去检查原因,好了,进入正题,解析apk时提示“ERROR getting 'android:icon' attribute: attribute is not a stringvalue”或者“ERROR getting 'android:label' attribute: attribute is not a stringvalue”,android清单文件中label有两种引用方式一种是硬编码一种是资源引用,无论是报上面哪种错误在我看来都是label的错,当清单文件有多个android:label的时候请使用:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="xxxxx">
<application
android:name=".xxxx"
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="应用名硬编码"
android:largeHeap="true"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:replace="android:label"
>


要注意检查的是清单文件中的所有资源引用类似于@string的android:label都需要转化成硬编码,至于icon在清单文件中只能以资源引用的方式存在,无需理会,下面提供一下本地aapt解析apk的方法:1.找到自己本地sdk下build-tools的文件夹,打开命令行,进入build-tools文件夹目录,执行aapt dump badging .apk2.查看是否有报错信息,若看得太吃力可以使用aapt dump badging .apk >1.txt将数据打印到文本中观看好了,就这么点内容了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android apk