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

在用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就可以成功打包了。


  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值