在分析apk时,apktool2.0.0rc3反编译成功,但重新打包出错如下:
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether resources has changed...
I: Building resources...
\res\values-v19\styles.xml:11: error: Error: No resource found that matches the given name: attr 'android:actionModeFindDrawable'.
\res\values-v19\styles.xml:10: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
\res\values-v19\styles.xml:21: error: Error: No resource found that matches the given name: attr 'android:actionModeFindDrawable'.
\res\values-v19\styles.xml:20: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Exception in thread "main" brut.androlib.AndrolibException: brut.androlib.AndrolibException: brut.common.BrutException:
could not exec command: .....
at brut.androlib.Androlib.buildResourcesFull(Androlib.java:437)
at brut.androlib.Androlib.buildResources(Androlib.java:374)
at brut.androlib.Androlib.build(Androlib.java:277)
at brut.androlib.Androlib.build(Androlib.java:250)
at brut.apktool.Main.cmdBuild(Main.java:225)
at brut.apktool.Main.main(Main.java:84)
Caused by: brut.androlib.AndrolibException: brut.common.BrutException: could not
exec command: .....
at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.jav
a:488)
at brut.androlib.Androlib.buildResourcesFull(Androlib.java:423)
... 5 more
Caused by: .....
at brut.util.OS.exec(OS.java:89)
at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.jav
a:482)
... 6 more
打开提示的文件
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="ptt_invisible" parent="@style/ptt">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowAnimationStyle">@android:style/Animation</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:actionModeFindDrawable">true</item>
<item name="android:actionModeShareDrawable">true</item>
</style>
<style name="ptt_light_invisible" parent="@style/ptt_light">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowAnimationStyle">@android:style/Animation</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:actionModeFindDrawable">true</item>
<item name="android:actionModeShareDrawable">true</item>
</style>
</resources>
既然提示无法识别资源标识,那尝试
删除看看。
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="ptt_invisible" parent="@style/ptt">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowAnimationStyle">@android:style/Animation</item>
<item name="android:colorBackgroundCacheHint">@null</item>
</style>
<style name="ptt_light_invisible" parent="@style/ptt_light">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowAnimationStyle">@android:style/Animation</item>
<item name="android:colorBackgroundCacheHint">@null</item>
</style>
</resources>
重新打包成功。
完全没有技术含量,只是说明了一个问题,碰到apktool出错,不用慌,有的错误是很好解决的。
经过与看雪的朋友讨论与实践,得出第二种方法。
原因:
不同level的API造成的。
解决方法:
在反编译之前把C:\Users\用户名\apktool\framework文件夹下面的1.apk删除,因为apktool rc3已经采用了api21的framework.jar里面的resources.arsc.
android-framework.jar 内置在apktool.jar
apktool.jar:apktool.jar\brut\androlib\android-framework.jar
源码目录:brut.apktool/apktool-lib/src/main/resources/brut/androlib/android-framework.jar
补充 下,1.apk其实就是android-framework.jar