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

Apktool编译出现“error: Public symbol aaa/bbb declared here is not defined.”的解决办法

2015-01-15 11:37 1361 查看
在用Apktool反编译一个应用的时候正常,没做任何修改,但是在回编译的时候出现了大量的“error: Public symbol aaa/bbb declared here is not defined.”这种错误,费了一些功夫搜了不少答案,终于把问题解决了。

首先贴一下apktool官网上的FAQ:

"error: Public symbol aaa/bbb declared here is not defined."

Usually this isn't an issue by itself, but it's a symptom of other issue. It's general error which may be caused by various specific ones. If you are building an application and there is an error in one of files, this file is ignored and building procedure
goes on. Then you get plenty of above errors cause of missing files.

Just look above these errors, there you should find another, real ones. This is general rule for reading error messages: earlier messages are always more important, they might cause later ones.

If error messages are bigger than console/window buffer, so you can't read first lines of output, you will have to increase buffer size. Search for this in console properties.

大致意思就是要找到第一个出现错误的地方,后边的那一系列错误都是由第一个错误引起的。因为Ubuntu的控制台没办法一下子容纳那么多的错误信息,会把前边的报错信息冲掉,所以要把错误信息重定向到一个文件里。控制台里输入   apktool b XXXX 2>errlog.txt   就可以把报错信息打印到这个errlog.txt文件中了。

打开errlog.txt文件,前两行的报错信息大概是:

libpng error: Not a PNG file

ERROR: Failure processing PNG image /res/drawable/XXXX.png

因为应用不同,所以第二条信息会有一些偏差,但大意就是res文件夹下某个png文件不是合法png文件。

用file命令查看这个png文件,发现这其实并不是png格式,比如我遇到的这个图片信息就是  share_er_icon.png: JPEG image data, JFIF standard 1.01, comment: "CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 70"   。因为Apktool在回编译的时候会先检查是否是png后缀的文件,所有png后缀文件都会按png文件进行重打包处理,这样对于实际上不是png格式的文件来说,肯定会出错,所以把后缀名改成本来的样子就好了,比如我遇到的这个图片后缀名改成jpg就可以成功打包了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Apktool 破解 Android
相关文章推荐