kuter007 / android-apktool

Automatically exported from code.google.com/p/android-apktool
Other
0 stars 0 forks source link

Installing com.htc.resources fails #534

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.apktool if com.htc.resources.apk

What is the expected output? What do you see instead?

"C:\Android\reverse engineering>apktool d -b com.htc.resources.apk
I: Using Apktool 2.0.0-Beta7 on com.htc.resources.apk
I: Loading resource table...
Exception in thread "main" brut.androlib.AndrolibException: Multiple resources:
spec=0x020500c0 dimen/title_primary_xs, config=-hdpi
        at brut.androlib.res.data.ResConfig.addResource(ResConfig.java:63)
        at brut.androlib.res.data.ResConfig.addResource(ResConfig.java:56)
        at brut.androlib.res.decoder.ARSCDecoder.readEntry(ARSCDecoder.java:199)

        at brut.androlib.res.decoder.ARSCDecoder.readConfig(ARSCDecoder.java:168
)
        at brut.androlib.res.decoder.ARSCDecoder.readType(ARSCDecoder.java:134)
        at brut.androlib.res.decoder.ARSCDecoder.readPackage(ARSCDecoder.java:10
9)
        at brut.androlib.res.decoder.ARSCDecoder.readTable(ARSCDecoder.java:81)
        at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:49)
        at brut.androlib.res.AndrolibResources.getResPackagesFromApk(AndrolibRes
ources.java:615)
        at brut.androlib.res.AndrolibResources.loadMainPkg(AndrolibResources.jav
a:74)
        at brut.androlib.res.AndrolibResources.getResTable(AndrolibResources.jav
a:66)
        at brut.androlib.Androlib.getResTable(Androlib.java:54)
        at brut.androlib.ApkDecoder.getResTable(ApkDecoder.java:216)
        at brut.androlib.ApkDecoder.setAnalysisMode(ApkDecoder.java:173)
        at brut.androlib.ApkDecoder.decode(ApkDecoder.java:88)
        at brut.apktool.Main.cmdDecode(Main.java:166)
        at brut.apktool.Main.main(Main.java:85)"

What version of the product are you using? On what operating system?
2.0.0 b7 - win8

Original issue reported on code.google.com by JanTay.D...@googlemail.com on 17 Oct 2013 at 3:17

Attachments:

GoogleCodeExporter commented 9 years ago
http://forum.xda-developers.com/showpost.php?p=46442216&postcount=2117

Original comment by connor.tumbleson on 17 Oct 2013 at 3:18

GoogleCodeExporter commented 9 years ago
Thx, will try to merge those changes back in.

Original comment by JanTay.D...@googlemail.com on 17 Oct 2013 at 3:24

GoogleCodeExporter commented 9 years ago
I don't want to just not support this apk, but its increasingly difficult to 
support this APK without breaking support for others.

Which is what I brought up in that XDA post.

Original comment by connor.tumbleson on 17 Oct 2013 at 8:20

GoogleCodeExporter commented 9 years ago
Np, merged the changes in and was able to install and no also decompile it.
But it broke a lot of functionality on other apks...framework-res wont install 
and lots of other wont decompile anymore..had to go back to 1.5.2 and install 
the framework files with it.

Seems the HTC framework is getting more and more a bitch.
If you need any help with debugging stuff let me know. I work each day several 
hours with apktool, reverse engeneering and adding stuff into HTC's framework.

Original comment by JanTay.D...@googlemail.com on 18 Oct 2013 at 5:11

GoogleCodeExporter commented 9 years ago
This is why I need to create a plugin system. I'm thinking some XML/JSON file, 
that has an ability to skip bytes and perform basic IF, AND, ORS in the 
json/xml file. So I can say

"if package == htc & size == 40"
read density as int
skip 2 bytes

or something like that. Need to figure out how to express conditionals in some 
flat xml/json file.

Original comment by connor.tumbleson on 18 Oct 2013 at 1:28

GoogleCodeExporter commented 9 years ago
Could you please confirm us whether the fix for the exception (while installing 
the htc resources apk, as listed below) would be available in final build of 
apktool i.e. v2?

E:\apktool>java -jar apktool_2.0.0b7.jar if com.htc.resources.apk
Exception in thread "main" brut.androlib.AndrolibException: Multiple resources:
spec=0x020500c0 dimen/title_primary_xs, config=-hdpi
        at brut.androlib.res.data.ResConfig.addResource(ResConfig.java:63)

Original comment by rajaonli...@gmail.com on 2 Nov 2013 at 6:16

GoogleCodeExporter commented 9 years ago
Nope I cannot confirm anything, some other user/developer can help identify the 
problem with that apk and push it upstream to me. Besides the obvious fix I 
have, maybe investigate why a couple ResSpecs of the APK have a 40 byte header, 
that size didn't even exist in ICS days and still doesn't today.

We are at KITKAT now with a 38 byte header. HTC's apk is now 1-2 years old and 
still packs an extra 2 bytes (more if you count the addition of rtl/ltr 
qualifier, since that didn't exist with com.htc.resources was released).

I've spent too much time with that APK and rather not mess with it again.

Original comment by connor.tumbleson on 2 Nov 2013 at 6:31

GoogleCodeExporter commented 9 years ago
@rajaonli

I'ts not nice, but I keep two diff versions of apktool atm.
I need the current public 1.5.2 for installing framework files and 
de/recompiling.
Works fine for me expect for one .jar file, thats the HtcExtension.jar.
That wont decompile with 1.5.2 but does fine with the current beta. Cant take 
the current beta for all other stuff, because it fails on several other apks.
Not nice...but it works.

Original comment by JanTay.D...@googlemail.com on 2 Nov 2013 at 6:59

GoogleCodeExporter commented 9 years ago
Exception in thread "main" brut.androlib.AndrolibException: Multiple resources: 
spec=0x0205004d dimen/title_primary_xs, config=-hdpi
        at brut.androlib.res.data.ResConfig.addResource(ResConfig.java:63)
        at brut.androlib.res.data.ResConfig.addResource(ResConfig.java:56)
        at brut.androlib.res.decoder.ARSCDecoder.readEntry(ARSCDecoder.java:199)
        at brut.androlib.res.decoder.ARSCDecoder.readConfig(ARSCDecoder.java:168)
        at brut.androlib.res.decoder.ARSCDecoder.readType(ARSCDecoder.java:134)
        at brut.androlib.res.decoder.ARSCDecoder.readPackage(ARSCDecoder.java:109)
        at brut.androlib.res.decoder.ARSCDecoder.readTable(ARSCDecoder.java:81)
        at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:49)
        at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:40)
        at brut.androlib.res.AndrolibResources.installFramework(AndrolibResources.java:687)
        at brut.androlib.Androlib.installFramework(Androlib.java:640)
        at brut.apktool.Main.cmdInstallFramework(Main.java:252)
        at brut.apktool.Main.main(Main.java:91)

JB "com.htc.resources". Time to bump priority on this.

Original comment by connor.tumbleson on 28 Nov 2013 at 12:42

GoogleCodeExporter commented 9 years ago
...btw. I added your suggested changes you linked in post #1.
Was able to decompile com.htc.resources and also recompiling works.
But it brakes a lot of things when you push it to the device. fonts + sizes are 
broken for example.

I decompiled it and recompiled without changes and did a hex diff...was way 
different and that shouldnt be the case, should it? (-:

Atm all themers hex edit the resources.asrc to make changes...pain in the ass 
(-:
Kitkat for the One will come around January/Feburary btw.

Original comment by JanTay.D...@googlemail.com on 28 Nov 2013 at 1:15

GoogleCodeExporter commented 9 years ago
Did some research with this today: http://pastebin.com/6hNQn18H

So this time I just wanted to see what happened, if instead of crashing I just 
threw errors if there was multiple resources: http://pastebin.com/xUX6nYdH

As you can see, there are a lot more resources than just the first one I 
encountered in the first paste. Ignoring them however apktool didn't seem to 
mind. (It was a hacky hacky change anyway, would be surprised if it even 
worked).

This led me to something else to think about. Using `aapt d --values resources 
com.htc.resouces.apk` I can see the values of every resource, which config its 
a part of and what not.

However, when apktool crashes it just says what the config was that it tried to 
enter. (When maybe a previous insertion was wrong, which caused the duplicate).

I'm thinking this plan of attack.

1. Add debug output to list every resource type, config, value being entered 
into HashMap. 
2. Compare that with the output of aapt resource while decompiling
3. Wait until we find a resource that was misidentified by Apktool
4. Fix that one.

Original comment by connor.tumbleson on 4 Jan 2014 at 12:41

GoogleCodeExporter commented 9 years ago
Issue 454 has been merged into this issue.

Original comment by connor.tumbleson on 16 Feb 2014 at 5:22

GoogleCodeExporter commented 9 years ago
This isnt really an installing com.htc.res issue but i was directed to post 
these files here. This is the framework from latest m8 release and the 
phone.apk that is giving this error 

http://forum.xda-developers.com/showpost.php?p=51826239&postcount=2319 

here is the zip containing the frameworks and apk

https://dl.dropboxusercontent.com/u/28511905/torublesome_M8_Phoneapk.zip

Original comment by steeleirons on 11 Apr 2014 at 8:46

GoogleCodeExporter commented 9 years ago
APKTOOL 2.0.0 RC3 + Phone.apk from M7 4.4.3 - exact same error as in #13.
https://www.dropbox.com/s/hlb6w4q9o71g60f/Phone.apk?dl=0

Original comment by rupepppa...@gmail.com on 7 Dec 2014 at 11:25

GoogleCodeExporter commented 9 years ago
use 1.5.2 apktool...it works with that one.

Original comment by JanTay.D...@googlemail.com on 8 Dec 2014 at 12:18