Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Cannot decompile LGSystemUI #822
Original issue 713 created by szecslasz on 2014-11-28T16:17:38.000Z:
17:14:59.154: [Error] - ApkTool.DecompileApk: 'ApkTool: I: Using Apktool 2.0.0-RC3 on CB5212.apk'
Comment #3 originally posted by connor.tumbleson on 2014-11-30T13:03:57.000Z:
lge-res.apk is being installed as 0.apk when its package id is 2.
base.apk & target apk both are package id of 127, but share resources
This causes the attributes to be undefined, hint "could not decode attr errors". Will investigate.
Comment #4 originally posted by hidingfromhidden on 2014-12-18T11:40:02.000Z:
I: Using Apktool 2.0.0-2bd1e5-SNAPSHOT on sg_gov_lta_taxitaxisg-4.apk
Comment #5 originally posted by connor.tumbleson on 2014-12-22T12:24:45.000Z:
# 713-1 makes no sense. Apktool is doing nothing wrong, the APK has shown in a hex output (http://i.imgur.com/o2oRkgK.png) has the package ID (which is right before package name) as 00.
So I took a look at AOSP documentation. https://github.com/android/platform_frameworks_base/blob/master/include/androidfw/ResourceTypes.h#L833
So maybe lge-res.apk is not a base package or maybe its some new fancy method of obfuscation / fancy OEM tricks. Since the error message of # 713-2 doesn't have a package ID of 0x00 or 0x02, then its probably safe to say this isn't the problem.
Investigation of # 713-2 is as follows. Using the pattern of installing the frameworks. The APKs included from comment # 2 showed.
i) com.lge.qremote.apk - no issue decoding
So basically (iii) is a completely non-related bug. The apks of interest are (v), (vii) and (ix).
Comment #6 originally posted by connor.tumbleson on 2014-12-22T12:28:24.000Z:
All return results. This points towards an improper decoding and assigning of resources on Apktool's side. This is better than having to attempt a merge of a resource pool between alike package ids. The culprit seems to be apktool's resource decoding.
Comment #7 originally posted by connor.tumbleson on 2014-12-22T13:22:45.000Z:
We have attributes that have references to internal resources (0x7F), so ie you have attr="@0x7F080000" etc. We try to follow this reference, but it hasn't been decoded yet so we encounter an UndefinedRes error.
I need to add support for delayed loading of attributes. These attributes are present after the APK is fully loaded, but since we decode as we load we encounter errors. We should decode all resources, but tag the attrs that need to be decoded later.
Usually this hasn't been a problem since attrs are first or the attr is from a shared public framework.
Comment #8 originally posted by connor.tumbleson on 2014-12-22T22:04:01.000Z:
Unfortunately re-locating this reference in the file is quite difficult. We would have to reparse the XML files and then crawl them looking for our reference to change. This is damn slow, especially if we need to do it for 100+ files. I need to adapt apktool to delay writing of files if it has unresolved resources.
However, apktool isn't multi-threaded so things go in turns and simply cannot be paused as that will prevent the next file from being decoded and thus a deadlock since we have a circle of waiting.
This is a big undertaking. I'm going to take a few days and talk to some people and try and figure out a good plan of attack for this, as I fear more apks/oems will be affected soon.
This exact problem happened before with missing name/value pairs in the manifest. Except these missing attrs were public (0x01), so I could simply reference the framework for the resource. This I believe was bug # 512.
Comment #9 originally posted by connor.tumbleson on 2014-12-24T14:25:08.000Z:
This block of code shows the mapping of the package name to ID. However, this struct is found no-where in the offending resources.arsc. You can find the first package name of "com lge" for the ResTable_package struct, but none other so finding the true packageId is unknown to me still.
I've been looking at the related commits which introduced shared packages
Though no luck. Enjoy the holidays. Will research more soon.
Comment #11 originally posted by yoav.goop on 2014-12-26T07:32:55.000Z:
apktool if framework-res.apk
now in java based on the github repo:
ApkDecoder decoder = new ApkDecoder();
דצמ 26, 2014 9:31:05 AM brut.androlib.res.AndrolibResources loadFrameworkPkg
דצמ 26, 2014 9:31:06 AM brut.androlib.res.AndrolibResources loadFrameworkPkg
Exception in thread "main" java.lang.NullPointerException
Process finished with exit code 1