图像 010

C:\apk\s\res\values\public.xml:224: error: Public entry identifier 0x7f03013d en
try index is larger than available symbols (index 317, total symbols 315).
C:\apk\s\res\values\public.xml:224: error: Public symbol drawable/status_bar_ite
m_background declared here is not defined.
C:\apk\s\res\values\public.xml:239: error: Public entry identifier 0x7f03014d en
try index is larger than available symbols (index 333, total symbols 315).
C:\apk\s\res\values\public.xml:239: error: Public symbol drawable/status_bar_not
ification_row_background_color declared here is not defined.
C:\apk\s\res\values\public.xml:238: error: Public entry identifier 0x7f03014c en
try index is larger than available symbols (index 332, total symbols 315).
C:\apk\s\res\values\public.xml:238: error: Public symbol drawable/status_bar_rec
ents_app_thumbnail_background declared here is not defined.
C:\apk\s\res\values\public.xml:225: error: Public entry identifier 0x7f03013e en
try index is larger than available symbols (index 318, total symbols 315).
C:\apk\s\res\values\public.xml:225: error: Public symbol drawable/status_bar_rec
ents_background declared here is not defined.
C:\apk\s\res\values\public.xml:237: error: Public entry identifier 0x7f03014b en
try index is larger than available symbols (index 331, total symbols 315).
C:\apk\s\res\values\public.xml:237: error: Public symbol drawable/status_bar_rec
ents_background_solid declared here is not defined.
C:\apk\s\res\values\public.xml:226: error: Public entry identifier 0x7f03013f en
try index is larger than available symbols (index 319, total symbols 315).
C:\apk\s\res\values\public.xml:226: error: Public symbol drawable/status_bar_set
tings_slider_disabled declared here is not defined.
C:\apk\s\res\values\public.xml:227: error: Public entry identifier 0x7f030140 en
try index is larger than available symbols (index 320, total symbols 315).
C:\apk\s\res\values\public.xml:227: error: Public symbol drawable/status_bar_tic
ker_background declared here is not defined.
C:\apk\s\res\values\public.xml:228: error: Public entry identifier 0x7f030141 en
try index is larger than available symbols (index 321, total symbols 315).
C:\apk\s\res\values\public.xml:228: error: Public symbol drawable/status_bar_tog
gle_button declared here is not defined.
C:\apk\s\res\values\public.xml:229: error: Public entry identifier 0x7f030142 en
try index is larger than available symbols (index 322, total symbols 315).
C:\apk\s\res\values\public.xml:229: error: Public symbol drawable/ticker_backgro
und declared here is not defined.
C:\apk\s\res\values\public.xml:234: error: Public entry identifier 0x7f030148 en
try index is larger than available symbols (index 328, total symbols 315).
C:\apk\s\res\values\public.xml:234: error: Public symbol drawable/ticker_backgro
und_color declared here is not defined.
C:\apk\s\res\values\public.xml:429: error: Public entry identifier 0x7f030143 en
try index is larger than available symbols (index 323, total symbols 315).
C:\apk\s\res\values\public.xml:429: error: Public symbol drawable/title_bar_shad
ow declared here is not defined.
C:\apk\s\res\values\public.xml:244: error: Public entry identifier 0x7f030152 en
try index is larger than available symbols (index 338, total symbols 315).
C:\apk\s\res\values\public.xml:244: error: Public symbol drawable/toolbox_backgr
ound declared here is not defined.
C:\apk\s\res\values\public.xml:236: error: Public entry identifier 0x7f03014a en
try index is larger than available symbols (index 330, total symbols 315).
C:\apk\s\res\values\public.xml:236: error: Public symbol drawable/translucent_st
atus_bar_background declared here is not defined.
C:\apk\s\res\values\public.xml:230: error: Public entry identifier 0x7f030144 en
try index is larger than available symbols (index 324, total symbols 315).
C:\apk\s\res\values\public.xml:230: error: Public symbol drawable/wifi_cpw_ppp_p
rompt_icon declared here is not defined.
Exception in thread "main" brut.androlib.AndrolibException: brut.common.BrutExce
ption: could not exec command: [aapt, p, --min-sdk-version, 15, --target-sdk-ver
sion, 15, -F, C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\APKTOOL5170265888679915855.tmp,
-I, C:\Documents and Settings\Administrator\apktool\framework\1.apk, -S, C:\apk
\s\res, -M, C:\apk\s\AndroidManifest.xml]
        at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.jav
a:255)
        at brut.androlib.Androlib.buildResourcesFull(Androlib.java:324)
        at brut.androlib.Androlib.buildResources(Androlib.java:269)
        at brut.androlib.Androlib.build(Androlib.java:192)
        at brut.androlib.Androlib.build(Androlib.java:174)
        at brut.apktool.Main.cmdBuild(Main.java:188)
        at brut.apktool.Main.main(Main.java:70)
Caused by: brut.common.BrutException: could not exec command: [aapt, p, --min-sd
k-version, 15, --target-sdk-version, 15, -F, C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\
APKTOOL5170265888679915855.tmp, -I, C:\Documents and Settings\Administrator\apkt
ool\framework\1.apk, -S, C:\apk\s\res, -M, C:\apk\s\AndroidManifest.xml]
        at brut.util.OS.exec(OS.java:83)
        at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.jav
a:253)
        ... 6 more

C:\apk>

 

上面是回编译华为U8825D的systemui.apk(没有改动)所遇到的错误提示。

作为初学者的我曾经百思不得其解,到处询问也没有明确答案,终于在不懈努力下,问题得以解决。

 

这样的一大串错误提示看起来确实挺唬人,其实都是一个意思,拿第一行为例

C:\apk\s\res\values\public.xml:240: error: Public entry identifier 0x7f03014e entry index is larger than available symbols (index 334, total symbols 315).
C:\apk\s\res\values\public.xml:240: error: Public symbol drawable/notification_header_bg declared here is not defined.

 

出现这样的错误提示告诉我们public.xml中的第240行,id为0x7f030144e的行出现了问题。

 

那到底出了什么问题呢?什么是”entry index is larger than available symbols”?334和315到底是什么意思?“not defined”没有定义是怎么回事?

这都是我当初会问的问题,而且问了不止N遍。

 

我们来看下public.xml中的240行到底写了什么 240   <public type="drawable" name="notification_header_bg" id="0x7f03014e" />

有什么问题呢?貌似没有什么问题。这不是写的清楚明白的么?让我们结合上下文来看。

用Notepad++打开public.xml,

在这个”drawable”类中起始行是173,id为0x7f03000a。结束行是487,id为0x7f030126 。 行数487-173=314,这不就是”total symbols 315“的含义么,315即为总行数。

同样在这个”drawable”类中起始id是0x7f030000(第193行) ,结束id为0x7f030153(第245行),为什么不是上面的0x7f030126(第487行)?因为行数虽然是按顺序排列,但id可不是,最大的id有可能在行的中间,所以很多教程说的在最后添加id可不是跟着最后一行的id,而是同类中的最大id后添加。

“drawable起始id在193行”

{240行id”0x7f03014e“} - {起始id”0x7f030000“} = 14e,十六进制14e换算为十进制为334,看到了没这就是334的含义。

就是说240行id定义的是334号,结果总行数为315,超出了总行数的限制,于是报错。这是因为id不连续造成的。

 

打个比方,大家去银行取钱要拿号排队,如果总人数为315人,结果号拿到了334,意味着什么?中间有人拿了号没取钱就走了呗。银行可以,程序不行,它只会按顺序读取,少一个就出错。告诉你“not defined”。

 

public.xml就像个记账本,所有大事小事都记在上边。按类型分好后,再按id排序。如果反编译的时候出现新的项(如图片),public.xml会自动加入id,但这时已不能保证后续兼容性。

 

在public.xml中同类(如drawable)id定义必须是连续的,但行顺序可能不连续,比如同类中最后行的id并不一定最大,最大的可能在同类中间。

 

C:\apk\s\res\values\public.xml:427: error: Public entry identifier 0x7f03013b en
try index is larger than available symbols (index 315, total symbols 315).
所以从每一个大过或者等于315的id序列都会报错。

总共是315,为什么315也会报错?因为id不是从1开始而是从0开始,315就是第316了。

  

systemui.apk中的错误看图,从f0后应该是f1,这里开始id不连续。注意行数并没有连续,这是可以的。

图像 004

  

右边是加入精确百分比电量的,id连续,所以不会出错。

图像 005

 

“drawable”结束, “layout”起始。如图,类别转换id可以从30000跳转到40000

图像 007

 

出错的原因可能是apktool版本过低或者是原文件本身有问题。修改id可能会导致不可预见的问题。

 

例:手工删除错误id,让public.xml自动生成,后修改systemui.apk状态栏透明度颜色值,无效。具体原因探索中。

 

以下为引用

当我们对public.xml做了改动后,执行make update-api命令,相应的current.xml就会添加这些改动。因为这些值按类型被放在不同的段上,类型相同的必须连续存放,不指定id值的话系统会自动计算出下一个值。
添加id的方法:1)在ids.xml中添加公共id项,在public.xml中也添加相应的id项。这种办法没有兼容性,会与后面的版本产生冲突。
2)在ids.xml中添加公共id项,每一项前面加一行<!-- @hide -->的注释,这样就不用在public.xml中添加相应的项了。源码中是/** @hide  */的形式,这样current中就不会有相应的段了。        3)在自己写的xml中,使用android:id = "@+id/id_name"的形式,就和在eclipse中一样,搜一下会发现android源码中也有这么用的,这样ids.xml和public.xml都不用改,兼容性我还不确定。

当然,strings和ids还得手动添加public.xml才会自动生成
手动添加strings的内容到strings.xml public.xml就自动生成了
attr.xml 和strings.xml  中定义的,在public.xml 中也会定义ID