Join GitHub today
Multiple ResTypeSpecs in a row, cannot be decoded. #1031
Apktool 2.0.1 crashes and produces no results with this apk https://play.google.com/store/apps/details?id=it.ingdirect.app
Okay, spent the morning on this one.
The problem shown above is just the failure point. The real problem occurs much early in the process. For example.
This means the failure is occurring way earlier. So I breakpointed after the first problem. We read a
and usually then we read the corresponding configuration after that - https://github.com/android/platform_frameworks_base/blob/master/include/androidfw/ResourceTypes.h#L1284
However, the type header is set to that of another type vs a configuration, so Apktool sets all the resources from that type to false values (APKTOOL_DUMMY, etc).
referenced this issue
Oct 12, 2015
hi, ths your work.
the newest 2.0.2 version can work on LocusPro with the -r option.
pushed a commit
Oct 15, 2015
Started looking at this. Notes for myself
Seems our failure occurs in the first
Okay disregard previous comment by myself. We correctly read the first
At this point either I don't understand this failure or a bug has been discovered in the root way apktool functions. If apktool does not find a configuration for a given type, it fills it with dummy data. According to the comment here - https://github.com/iBotPeaches/platform_frameworks_base/blob/apktool-mm/include/androidfw/ResourceTypes.h#L850
The problem Apktool has is it expects Type --> Config, Type --> Config, etc, etc. Currently this application goes Type --> Type, which isn't expected nor supported yet.
Additionally Ingress 1.89.0 has this exact problem. Time to bump priority. This is a major major major bug now. Affecting more and more apps daily.
Another comment for myself. Sorry for notifications.
I was correct in (#1031 (comment)) comment. All the TypeSpecs are read in a row instead of going TypeSpec -> Config -> Entry. The new order is TypeSpec -> TypeSpec --> ... -> TypeSpec, then finally Config -> Entry -> Entry -> Entry --> Config -> Entry etc.
So I adapted the code to read all the
Our decoder needs a tiny rewrite to support this change, without breaking previous apks. Still on a mission to figure out how to get this to happen myself in a smaller test apk. Building Marshmallow apks by myself in Android Studio does not trigger this change. AAPT would be responsible for this, so maybe I'm missing a configuration/parameter value that is causing it.
Research / fixes are ongoing.
Okay, another update.
Patching the previous comment problem was a success. Types were correctly associated with the configurations they were part of, thus preserving the correct resource ids. In the case of Ingress 1.89.0, completely read the first block of resources. The [default] configuration of 32 attributes.
Next up was
This is where things get strange. Reading the
Tis progress though
Okay another update x2.
The problem now, is that like previous comments I built a FIFO Queue (First In, First Out). Also known as a
Need to update the
Good News - Types & TypeSpecs are correctly load for both sparse and densely packed apks.
Okay another update x3
Per the last comment.
The next issue we encountered was handling INVALID TYPE lines. Some APKs have lines like such
I'm still not quite sure why those occur, but they do. To handle this we generate a bogus
Multiple errors occurred with this logic as resources were duplicated. IE a bogus resource was created for a legitimate resource. A temporary and hacky fix, which was nothing more than disabling the Missing Res Specs was put into place. We were left with the stacktrace shown above. We correctly read the entire ResTable. Hurrah :)
While decoding files back to human readable form, we encounter an error while following a reference on a file. So this resource doesn't exist. Why?
Well its obvious. The "Missing Res Specs" are disabled.
I wonder what that bad resource is.
Yep, one of those :)
I just need to patch MissingResSpecs back in Apktool, and make sure it works and knock on wood. This is fixed.
Okay another update x4.
We did it :)
The current fix for