New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
APKTool 2.0.2 - ClassCastException ResStringValue -> ResAttr #1060
Comments
Can you share this apk? |
Hmm, I'm afraid not (NDA and other legal restrictions). I'll try to wiz-up an app which I can share (using the same config, but without the code). |
If you can whip up one with the same error, ill take a look |
Well, the good news is that the Android app I tried to whip-up doesn't have this problem. I've taken the liberty of downloading the APKTool sources and followed the stacktrace to where the exception is thrown. I updated the code to: public class ResAttrDecoder {
public String decode(int type, int value, String rawValue, int attrResId)
throws AndrolibException {
ResScalarValue resValue = mCurrentPackage.getValueFactory().factory(
type, value, rawValue);
String decoded = null;
if (attrResId > 0) {
try {
ResTable resTable = getCurrentPackage().getResTable();
ResResource o = resTable.getResSpec(attrResId).getDefaultResource();
try {
ResAttr attr = (ResAttr) getCurrentPackage().getResTable()
.getResSpec(attrResId).getDefaultResource().getValue();
decoded = attr.convertToResXmlFormat(resValue);
} catch (ClassCastException e) {
System.out.println("DECODING ---------------------------------------------");
System.out.println("ResValue : " + resValue.toString());
System.out.println("Fullname: " + resTable.getResSpec(attrResId).getFullName());
System.out.println("Trying to decode RawValue: " + rawValue);
ResStringValue val = (ResStringValue) o.getValue();
System.out.println("ResStringValue: " + val.toString());
System.out.println("Value contains : " + val.encodeAsResXmlValue());
decoded = val.encodeAsResXmlValue();
}
} catch (UndefinedResObject ex) {
// ignored
}
}
return decoded != null ? decoded : resValue.encodeAsResXmlAttr();
}
... And I get this as output:
It also gets this error after parsing the "application" tag of the manifest. Strangely enough, I have no values or attributes defined as "padding", nor the private_resource_pad22. Could it be related to any of the libraries which are included?
|
Yeah, I see the problem. Attributes should not be decoded as a What you could do to help is dump the |
Dumped the (int) value, which is 16844011. The grep didn't return any results though (not even for its hex-variant)... ...
} catch (ClassCastException e) {
System.out.println("DECODING ---------------------------------------------");
System.out.println("AttrResId: " + attrResId);
System.out.println(">>> " + o.getResSpec().getId().toString());
... Output:
Grep result:
|
^ Give that commit a shot. |
Works like a charm! Thanks 👍 |
@kvandermast Has the service team been able to resolve the issue with uploading the to the MobileIron MDM? Our team is experiencing a similar issue at the moment. |
@jeetjshah the issue has been escalated to MobileIron, whom recognized the problem and are preparing a patch release to fix the issue. A release date has not been communicated. But tests on the development environment indicated that the problem was fixed with a new version of the tool. |
I ran into this issue too. I tried versions of apktool until I got the same error as Mobile Iron (2.0.0-RC4). I finally noticed that I was failing on the same resource identifier as noted above. Googling this value got a hit on the android:fullBackupContent attribute that I had defined in the application element in AndroidManifest.xml (see http://developer.android.com/reference/android/R.attr.html). Removing that value from the manifest allows apktool 2.0.0RC4 to work and I can load it into Mobile Iron. |
A lot of bugs are happening related to casting types. The problem stems from The current fixes of simply identifying types and reacting is hacky but will work in short term. The issue this was reported for is fixed. If there are other apks that experience |
We are using a MobileIron Store to distribute our enterprise apps to the employees. We just released a new version and the service team is unable to upload the APK to the Store. I can trace it back to MobileIron decompile the APK (God knows why).
When I try to decompile the apk via command line, it throws the ClassCastException:
Environment:
Android build tools:
Let me know if you need more information.
Regards,
Kris
The text was updated successfully, but these errors were encountered: