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

Exception in thread "main" brut.androlib.AndrolibException: Multiple res specs: attr/name #894

Closed
iBotPeaches opened this Issue Mar 18, 2015 · 23 comments

Comments

Projects
None yet
@iBotPeaches
Owner

iBotPeaches commented Mar 18, 2015

Original issue 785 created by sh37092 on 2015-03-17T03:26:48.000Z:

What steps will reproduce the problem?
1.Decode mobileqq_android.apk
2.
3.

What is the expected output? What do you see instead?
I: Using Apktool 2.0.0-RC4 on mobileqq_android.apk
I: Loading resource table...

Exception in thread "main" brut.androlib.AndrolibException: Multiple res specs: attr/name
    at brut.androlib.res.data.ResType.addResSpec(ResType.java:58)
    at brut.androlib.res.decoder.ARSCDecoder.readEntry(ARSCDecoder.java:213)
    at brut.androlib.res.decoder.ARSCDecoder.readConfig(ARSCDecoder.java:188)
    at brut.androlib.res.decoder.ARSCDecoder.readType(ARSCDecoder.java:156)
    at brut.androlib.res.decoder.ARSCDecoder.readPackage(ARSCDecoder.java:113)
    at brut.androlib.res.decoder.ARSCDecoder.readTable(ARSCDecoder.java:78)
    at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:47)
    at brut.androlib.res.AndrolibResources.getResPackagesFromApk(AndrolibResources.java:622)
    at brut.androlib.res.AndrolibResources.loadMainPkg(AndrolibResources.java:73)
    at brut.androlib.res.AndrolibResources.getResTable(AndrolibResources.java:65)
    at brut.androlib.Androlib.getResTable(Androlib.java:63)
    at brut.androlib.ApkDecoder.setTargetSdkVersion(ApkDecoder.java:209)
    at brut.androlib.ApkDecoder.decode(ApkDecoder.java:92)
    at brut.apktool.Main.cmdDecode(Main.java:165)
    at brut.apktool.Main.main(Main.java:81)

What version of the product are you using? On what operating system?
Apktool 2.0.0-RC4 on MacOSX with Java 1.8_40

Please provide any additional information below.
You can download mobileqq_android.apk from http://down.myapp.com/myapp/qqteam/AndroidQQ/mobileqq_android.apk

@BobCromwell

This comment has been minimized.

Show comment
Hide comment
@BobCromwell

BobCromwell Apr 9, 2015

met same issue

BobCromwell commented Apr 9, 2015

met same issue

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Apr 9, 2015

Owner

@BobCromwell Do you have an apk to upload? The more apks of the similar issue I can get the better.

Owner

iBotPeaches commented Apr 9, 2015

@BobCromwell Do you have an apk to upload? The more apks of the similar issue I can get the better.

@amir1111

This comment has been minimized.

Show comment
Hide comment
@amir1111

amir1111 May 20, 2015

i have 2 apks like this, compressed them to this link - http://www.filedropper.com/multipleres
I'm using apktool v2.0.0 on Windows 7 with Java 1.8_40

amir1111 commented May 20, 2015

i have 2 apks like this, compressed them to this link - http://www.filedropper.com/multipleres
I'm using apktool v2.0.0 on Windows 7 with Java 1.8_40

@iBotPeaches iBotPeaches added the Bug label May 20, 2015

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches May 20, 2015

Owner

Yes, both of those APKs exhibit the same problem.

Owner

iBotPeaches commented May 20, 2015

Yes, both of those APKs exhibit the same problem.

@mooreliu

This comment has been minimized.

Show comment
Hide comment
@mooreliu

mooreliu Aug 4, 2015

Does this problem solved ?

mooreliu commented Aug 4, 2015

Does this problem solved ?

@TimeThief0723

This comment has been minimized.

Show comment
Hide comment
@TimeThief0723

TimeThief0723 Aug 13, 2015

How to debug apktool myself?

TimeThief0723 commented Aug 13, 2015

How to debug apktool myself?

@paulobrien

This comment has been minimized.

Show comment
Hide comment
@paulobrien

paulobrien Nov 3, 2015

I have the same issue with this SystemUI.apk (frameworks are also included):

http://content.modaco.net/dropzone/h7systemuibug.zip

P

paulobrien commented Nov 3, 2015

I have the same issue with this SystemUI.apk (frameworks are also included):

http://content.modaco.net/dropzone/h7systemuibug.zip

P

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Nov 3, 2015

Owner

Having some trouble extracting this.

ibotpeaches@tombstone:~/Downloads/Apktool/Bug894$ unzip h7systemuibug.zip 
Archive:  h7systemuibug.zip
error [h7systemuibug.zip]:  missing 266 bytes in zipfile
  (attempting to process anyway)
error [h7systemuibug.zip]:  attempt to seek before beginning of zipfile
  (please check that you have transferred or created the zipfile in the
  appropriate BINARY mode and that you have compiled UnZip properly)
  (attempting to re-compensate)
  inflating: framework-res.apk       
  error:  invalid compressed data to inflate
file #2:  bad zipfile offset (local header sig):  8641411
  (attempting to re-compensate)
file #2:  bad zipfile offset (local header sig):  8641411
file #3:  bad zipfile offset (local header sig):  19368381
ibotpeaches@tombstone:~/Downloads/Apktool/Bug894$ md5sum h7systemuibug.zip 
c36934e9203a48665bc4e8cb361028c3  h7systemuibug.zip
Owner

iBotPeaches commented Nov 3, 2015

Having some trouble extracting this.

ibotpeaches@tombstone:~/Downloads/Apktool/Bug894$ unzip h7systemuibug.zip 
Archive:  h7systemuibug.zip
error [h7systemuibug.zip]:  missing 266 bytes in zipfile
  (attempting to process anyway)
error [h7systemuibug.zip]:  attempt to seek before beginning of zipfile
  (please check that you have transferred or created the zipfile in the
  appropriate BINARY mode and that you have compiled UnZip properly)
  (attempting to re-compensate)
  inflating: framework-res.apk       
  error:  invalid compressed data to inflate
file #2:  bad zipfile offset (local header sig):  8641411
  (attempting to re-compensate)
file #2:  bad zipfile offset (local header sig):  8641411
file #3:  bad zipfile offset (local header sig):  19368381
ibotpeaches@tombstone:~/Downloads/Apktool/Bug894$ md5sum h7systemuibug.zip 
c36934e9203a48665bc4e8cb361028c3  h7systemuibug.zip
@paulobrien

This comment has been minimized.

Show comment
Hide comment
@paulobrien

paulobrien Nov 3, 2015

Not sure what happened there!

Reuploaded:

http://content.modaco.net/dropzone/h7systemuibug.2.zip

Thanks for your help. :) This is from the Honor 7 however (Huawei based), which could be the cause of the problem!

P

paulobrien commented Nov 3, 2015

Not sure what happened there!

Reuploaded:

http://content.modaco.net/dropzone/h7systemuibug.2.zip

Thanks for your help. :) This is from the Honor 7 however (Huawei based), which could be the cause of the problem!

P

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Nov 3, 2015

Owner

Yeah these apks have qualifiers that apktool does not know about.

opta# and optb#. Which causes all the strange errors, which isn't exactly the same as OP issue. Short of reverse engineering, I have no idea what these qualifiers serve, which makes it difficult to support, if at all. I believe this then is the same problem as in #836

Owner

iBotPeaches commented Nov 3, 2015

Yeah these apks have qualifiers that apktool does not know about.

opta# and optb#. Which causes all the strange errors, which isn't exactly the same as OP issue. Short of reverse engineering, I have no idea what these qualifiers serve, which makes it difficult to support, if at all. I believe this then is the same problem as in #836

@Henry2o1o

This comment has been minimized.

Show comment
Hide comment
@Henry2o1o

Henry2o1o Dec 4, 2015

here the same problem

LBE Security Master - Beta_6.1.2197.apk

Henry2o1o commented Dec 4, 2015

here the same problem

LBE Security Master - Beta_6.1.2197.apk

@13572293130

This comment has been minimized.

Show comment
Hide comment
@13572293130

13572293130 Dec 9, 2015

The reason for "Exception in thread "main" brut.androlib.AndrolibException: Multiple res specs:
attr/0" is: res directory name and file name is proguarded. reference to http://bbs.pediy.com/showthread.php?p=1308494

13572293130 commented Dec 9, 2015

The reason for "Exception in thread "main" brut.androlib.AndrolibException: Multiple res specs:
attr/0" is: res directory name and file name is proguarded. reference to http://bbs.pediy.com/showthread.php?p=1308494

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Dec 26, 2015

Owner

Started researching this. Most resources have the same key as shown

      spec resource 0x7f010000 com.tencent.mobileqq:attr/name: flags=0x00000000
      spec resource 0x7f010001 com.tencent.mobileqq:attr/name: flags=0x00000000
      spec resource 0x7f010002 com.tencent.mobileqq:attr/name: flags=0x00000000
      spec resource 0x7f010003 com.tencent.mobileqq:attr/name: flags=0x00000000
      spec resource 0x7f010004 com.tencent.mobileqq:attr/name: flags=0x00000000
      spec resource 0x7f010005 com.tencent.mobileqq:attr/name: flags=0x00000000
      spec resource 0x7f010006 com.tencent.mobileqq:attr/name: flags=0x00000000
      spec resource 0x7f010007 com.tencent.mobileqq:attr/name: flags=0x00000000
      spec resource 0x7f010008 com.tencent.mobileqq:attr/name: flags=0x00000000
      spec resource 0x7f010009 com.tencent.mobileqq:attr/name: flags=0x00000000
      spec resource 0x7f01000a com.tencent.mobileqq:attr/name: flags=0x00000000

Apktool stores based on type/key_name. This should be unique, but this proves otherwise. Hence the "double resource" errors. Anything on device goes by resourceId, so this doesn't cause a problem.

For apktool however, it does. I did a quick n dirty patch with Dexguard by just creating unique key names (f932394). Since the only place the human readable key name is used is resources, we know the dummy value name from the resourceId, so this doesn't break anything.

The correct fix may be as follows.

  1. If the key_name is null or empty, then replace with a dummy value that is unique. IE (APKTOOL_DUMMYVAL_{HEXID}).
  2. If the key_name is not empty, but a duplicate occurs. Append a number onto the end (Probably resourceId) to prevent having to keep track of a counter.
  3. During build, resources are followed to resourceIds which haven't changed so built apk should have the same functionality as original. Granted the decode application will look different, but the real key names have been destroyed/obfuscated/removed/something by Dexguard and other Obfuscation apps so we can't really ever use them.
  4. Or maybe we are attacking this problem wrong and apktool shouldn't check for unique key names, but then we still have the problem of writing duplicate key_names in human readable form.
Owner

iBotPeaches commented Dec 26, 2015

Started researching this. Most resources have the same key as shown

      spec resource 0x7f010000 com.tencent.mobileqq:attr/name: flags=0x00000000
      spec resource 0x7f010001 com.tencent.mobileqq:attr/name: flags=0x00000000
      spec resource 0x7f010002 com.tencent.mobileqq:attr/name: flags=0x00000000
      spec resource 0x7f010003 com.tencent.mobileqq:attr/name: flags=0x00000000
      spec resource 0x7f010004 com.tencent.mobileqq:attr/name: flags=0x00000000
      spec resource 0x7f010005 com.tencent.mobileqq:attr/name: flags=0x00000000
      spec resource 0x7f010006 com.tencent.mobileqq:attr/name: flags=0x00000000
      spec resource 0x7f010007 com.tencent.mobileqq:attr/name: flags=0x00000000
      spec resource 0x7f010008 com.tencent.mobileqq:attr/name: flags=0x00000000
      spec resource 0x7f010009 com.tencent.mobileqq:attr/name: flags=0x00000000
      spec resource 0x7f01000a com.tencent.mobileqq:attr/name: flags=0x00000000

Apktool stores based on type/key_name. This should be unique, but this proves otherwise. Hence the "double resource" errors. Anything on device goes by resourceId, so this doesn't cause a problem.

For apktool however, it does. I did a quick n dirty patch with Dexguard by just creating unique key names (f932394). Since the only place the human readable key name is used is resources, we know the dummy value name from the resourceId, so this doesn't break anything.

The correct fix may be as follows.

  1. If the key_name is null or empty, then replace with a dummy value that is unique. IE (APKTOOL_DUMMYVAL_{HEXID}).
  2. If the key_name is not empty, but a duplicate occurs. Append a number onto the end (Probably resourceId) to prevent having to keep track of a counter.
  3. During build, resources are followed to resourceIds which haven't changed so built apk should have the same functionality as original. Granted the decode application will look different, but the real key names have been destroyed/obfuscated/removed/something by Dexguard and other Obfuscation apps so we can't really ever use them.
  4. Or maybe we are attacking this problem wrong and apktool shouldn't check for unique key names, but then we still have the problem of writing duplicate key_names in human readable form.
@SetoKaiba

This comment has been minimized.

Show comment
Hide comment
@SetoKaiba

SetoKaiba Dec 29, 2015

I build apktool from master branch. It should include the f932394 commit. But it still failed with com.tencent.mobileqq.

I: Using Apktool 2.0.3-13b399-SNAPSHOT on mobileqq_android.apk
I: Loading resource table...
Exception in thread "main" brut.androlib.AndrolibException: Multiple res specs: attr/name
at brut.androlib.res.data.ResTypeSpec.addResSpec(ResTypeSpec.java:78)
at brut.androlib.res.decoder.ARSCDecoder.readEntry(ARSCDecoder.java:248)
at brut.androlib.res.decoder.ARSCDecoder.readTableType(ARSCDecoder.java:212)
at brut.androlib.res.decoder.ARSCDecoder.readTableTypeSpec(ARSCDecoder.java:154)
at brut.androlib.res.decoder.ARSCDecoder.readTablePackage(ARSCDecoder.java:116)
at brut.androlib.res.decoder.ARSCDecoder.readTableHeader(ARSCDecoder.java:78)
at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:47)
at brut.androlib.res.AndrolibResources.getResPackagesFromApk(AndrolibResources.java:544)
at brut.androlib.res.AndrolibResources.loadMainPkg(AndrolibResources.java:63)
at brut.androlib.res.AndrolibResources.getResTable(AndrolibResources.java:55)
at brut.androlib.Androlib.getResTable(Androlib.java:66)
at brut.androlib.ApkDecoder.setTargetSdkVersion(ApkDecoder.java:198)
at brut.androlib.ApkDecoder.decode(ApkDecoder.java:96)
at brut.apktool.Main.cmdDecode(Main.java:165)
at brut.apktool.Main.main(Main.java:81)

SetoKaiba commented Dec 29, 2015

I build apktool from master branch. It should include the f932394 commit. But it still failed with com.tencent.mobileqq.

I: Using Apktool 2.0.3-13b399-SNAPSHOT on mobileqq_android.apk
I: Loading resource table...
Exception in thread "main" brut.androlib.AndrolibException: Multiple res specs: attr/name
at brut.androlib.res.data.ResTypeSpec.addResSpec(ResTypeSpec.java:78)
at brut.androlib.res.decoder.ARSCDecoder.readEntry(ARSCDecoder.java:248)
at brut.androlib.res.decoder.ARSCDecoder.readTableType(ARSCDecoder.java:212)
at brut.androlib.res.decoder.ARSCDecoder.readTableTypeSpec(ARSCDecoder.java:154)
at brut.androlib.res.decoder.ARSCDecoder.readTablePackage(ARSCDecoder.java:116)
at brut.androlib.res.decoder.ARSCDecoder.readTableHeader(ARSCDecoder.java:78)
at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:47)
at brut.androlib.res.AndrolibResources.getResPackagesFromApk(AndrolibResources.java:544)
at brut.androlib.res.AndrolibResources.loadMainPkg(AndrolibResources.java:63)
at brut.androlib.res.AndrolibResources.getResTable(AndrolibResources.java:55)
at brut.androlib.Androlib.getResTable(Androlib.java:66)
at brut.androlib.ApkDecoder.setTargetSdkVersion(ApkDecoder.java:198)
at brut.androlib.ApkDecoder.decode(ApkDecoder.java:96)
at brut.apktool.Main.cmdDecode(Main.java:165)
at brut.apktool.Main.main(Main.java:81)

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Dec 29, 2015

Owner

It shouldn't work with that commit. com.tencent.mobileqq has multiple names of the same word. The fix was for resources that had no name (ie empty).

A fix to detect current resources and detect duplicates and avoid them by adding uniqueness needs to be added.

Owner

iBotPeaches commented Dec 29, 2015

It shouldn't work with that commit. com.tencent.mobileqq has multiple names of the same word. The fix was for resources that had no name (ie empty).

A fix to detect current resources and detect duplicates and avoid them by adding uniqueness needs to be added.

@SetoKaiba

This comment has been minimized.

Show comment
Hide comment
@SetoKaiba

SetoKaiba Dec 29, 2015

Thanks. I see. I misunderstood your words.

SetoKaiba commented Dec 29, 2015

Thanks. I see. I misunderstood your words.

@donly

This comment has been minimized.

Show comment
Hide comment

donly commented Dec 31, 2015

See this Chinese blog please, http://www.mak-blog.com/tencent-shell-crack.html

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Dec 31, 2015

Owner

Thanks @donly

Looks like 3 separate issues at hand here. I'll try and get the dex files to the smali project to confirm if those patches will work for that issue. Then I already have a duplicate resource patch underway.

These fixes won't make the 2.0.3 release today, but should make 2.1.0.

Owner

iBotPeaches commented Dec 31, 2015

Thanks @donly

Looks like 3 separate issues at hand here. I'll try and get the dex files to the smali project to confirm if those patches will work for that issue. Then I already have a duplicate resource patch underway.

These fixes won't make the 2.0.3 release today, but should make 2.1.0.

@proninyaroslav

This comment has been minimized.

Show comment
Hide comment
@proninyaroslav

proninyaroslav Jan 6, 2016

@iBotPeaches
When approximately wait 2.1.0 with fix?

proninyaroslav commented Jan 6, 2016

@iBotPeaches
When approximately wait 2.1.0 with fix?

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Jan 6, 2016

Owner

Well the fix hasn't happened yet, so no idea. My releases tend to be 2-3 months apart and I just released 2.0.3 on 12/31/2015 so probably in late February or early March.

Owner

iBotPeaches commented Jan 6, 2016

Well the fix hasn't happened yet, so no idea. My releases tend to be 2-3 months apart and I just released 2.0.3 on 12/31/2015 so probably in late February or early March.

@lucca2011

This comment has been minimized.

Show comment
Hide comment
@lucca2011

lucca2011 May 9, 2016

how to fix this problem now?

lucca2011 commented May 9, 2016

how to fix this problem now?

@VicV

This comment has been minimized.

Show comment
Hide comment
@VicV

VicV Jul 19, 2016

@iBotPeaches Giving you another ping on this one. :)

VicV commented Jul 19, 2016

@iBotPeaches Giving you another ping on this one. :)

@iBotPeaches iBotPeaches added this to the 2.2.0 milestone Aug 6, 2016

@iBotPeaches iBotPeaches self-assigned this Aug 6, 2016

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Aug 6, 2016

Owner

Sorry for delay on this issue. I've spent the past few days really working on it, and I can't seem to get rebuilding working yet, but decoding works. I'll get that pushed out here shortly.

➜  Bug894 apktool d mobileqq_android.apk -f
I: Using Apktool 2.2.0-e1dd43-SNAPSHOT on mobileqq_android.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: /home/ibotpeaches/.local/share/apktool/framework/1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Baksmaling classes.dex...
I: Baksmaling classes2.dex...
I: Baksmaling classes3.dex...
I: Baksmaling classes4.dex...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...

I've decided due to impending release of Android Nougat and the possibility that aapt2 (The 2nd iteration of aapt) will be out and thus changing the entire build side of apktool, I shouldn't spend too much time patching build support into a soon to be deprecated aapt binary.

Owner

iBotPeaches commented Aug 6, 2016

Sorry for delay on this issue. I've spent the past few days really working on it, and I can't seem to get rebuilding working yet, but decoding works. I'll get that pushed out here shortly.

➜  Bug894 apktool d mobileqq_android.apk -f
I: Using Apktool 2.2.0-e1dd43-SNAPSHOT on mobileqq_android.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: /home/ibotpeaches/.local/share/apktool/framework/1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Baksmaling classes.dex...
I: Baksmaling classes2.dex...
I: Baksmaling classes3.dex...
I: Baksmaling classes4.dex...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...

I've decided due to impending release of Android Nougat and the possibility that aapt2 (The 2nd iteration of aapt) will be out and thus changing the entire build side of apktool, I shouldn't spend too much time patching build support into a soon to be deprecated aapt binary.

iBotPeaches added a commit that referenced this issue Aug 6, 2016

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