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.2.2 - ClassCastException ResColorValue -> ResAttr #1444

Closed
hylo926 opened this Issue Feb 27, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@hylo926

hylo926 commented Feb 27, 2017

#1060
It is almost the same issue with above.
Apktook tried to cast ResStringValue to ResAttr and it got an exception.
Only this time it is ResColorValue.
I personally modified the source as above and rebuilt the apktool, and it decompiled the apk without a problem.
I'd like to report here just in case it is a bug.

10:36 $ git diff
diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/value/ResStyleValue.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/value/ResStyleValue.java
index cc96e65..acba323 100644
--- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/value/ResStyleValue.java
+++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/value/ResStyleValue.java
@@ -68,7 +68,7 @@ public class ResStyleValue extends ResBagValue implements
             if (resource.contains("ResReferenceValue@")) {
                 continue;
             } else if (resource.contains("ResStringValue@") || resource.contains("ResStyleValue@") ||
-                    resource.contains("ResBoolValue@")) {
+                    resource.contains("ResBoolValue@") || resource.contains("ResColorValue@")) {
                 name = "@" + spec.getFullName(res.getResSpec().getPackage(), false);
             } else {
                 ResAttr attr = (ResAttr) spec.getDefaultResource().getValue();

Information

  1. Apktool Version (apktool -version) - 2.2.2
  2. Operating System (Mac, Linux, Windows) - Windows
  3. APK From? (Playstore, ROM, Other) - Playstore

Stacktrace/Logcat

$ java -jar ../apktool_2.2.2.jar d -f xxx.apk
I: Using Apktool 2.2.2 on xxx.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: C:\Users\yyy\AppData\Local\apktool\framework\1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
Exception in thread "main" java.lang.ClassCastException: brut.androlib.res.data.value.ResColorValue cannot be cast to brut.androlib.res.data.value.ResAttr
        at brut.androlib.res.data.value.ResStyleValue.serializeToResValuesXml(ResStyleValue.java:74)
        at brut.androlib.res.AndrolibResources.generateValuesFile(AndrolibResources.java:517)
        at brut.androlib.res.AndrolibResources.decode(AndrolibResources.java:267)
        at brut.androlib.Androlib.decodeResourcesFull(Androlib.java:131)
        at brut.androlib.ApkDecoder.decode(ApkDecoder.java:108)
        at brut.apktool.Main.cmdDecode(Main.java:166)
        at brut.apktool.Main.main(Main.java:81)

Steps to Reproduce

  1. java -jar ../apktool_2.2.2.jar d -f xxx.apk
@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Mar 1, 2017

Owner

It seems like a hacky fix of mine to continually add all types to this check, when all it does it get the spec name. I think we can evolve this check to be a smarter to simply call this method, except in situations where its a ResReference and/or the object doesn't extend or support the ResAttr.

Any name of apk or link to playstore entry? Can email if private (ibotpeaches) (dot) gmail (dot) com, just so I don't have to waste time building a fake apk in order to duplicate this.

Owner

iBotPeaches commented Mar 1, 2017

It seems like a hacky fix of mine to continually add all types to this check, when all it does it get the spec name. I think we can evolve this check to be a smarter to simply call this method, except in situations where its a ResReference and/or the object doesn't extend or support the ResAttr.

Any name of apk or link to playstore entry? Can email if private (ibotpeaches) (dot) gmail (dot) com, just so I don't have to waste time building a fake apk in order to duplicate this.

@hylo926

This comment has been minimized.

Show comment
Hide comment
@hylo926

hylo926 Mar 5, 2017

I sent you a mail about the apk I used.
I hope it's not too late.

Yes, it's a hacky fix.
It would be good for all of us if you evolve this to a smarter way.

hylo926 commented Mar 5, 2017

I sent you a mail about the apk I used.
I hope it's not too late.

Yes, it's a hacky fix.
It would be good for all of us if you evolve this to a smarter way.

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Mar 15, 2017

Owner

APK obtained. Confirmed problem. Will work on a more enhanced fix.

Owner

iBotPeaches commented Mar 15, 2017

APK obtained. Confirmed problem. Will work on a more enhanced fix.

@iBotPeaches iBotPeaches removed the Accepted label Jun 23, 2017

xpirt added a commit to xpirt/Apktool that referenced this issue Aug 27, 2017

@iBotPeaches iBotPeaches closed this in #1601 Aug 27, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment