Skip to content
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

[BUG] AndroidManifest.xml is missing attributes when decoding apk #2981

Closed
HeyItsMedz opened this issue Jan 18, 2023 · 6 comments · Fixed by #3123
Closed

[BUG] AndroidManifest.xml is missing attributes when decoding apk #2981

HeyItsMedz opened this issue Jan 18, 2023 · 6 comments · Fixed by #3123
Labels
Milestone

Comments

@HeyItsMedz
Copy link

HeyItsMedz commented Jan 18, 2023

Information

  1. Apktool Version (apktool -version) - 2.7.0
  2. Operating System (Mac, Linux, Windows) - macOS Monterey 12.0.1
  3. APK From? (Playstore, ROM, Other) - https://m.apkpure.com/all-4-watch-live-on-demand/com.channel4.ondemand/download

Stacktrace/Logcat

I: Using Apktool 2.7.0 on All4.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: /Users/Mehdi/Library/apktool/framework/1.apk
I: Regular manifest package...
[Fatal Error] :4:22: Element type "uses-permission" must be followed by either attribute specifications, ">" or "/>".
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Baksmaling classes.dex...
I: Baksmaling classes2.dex...
I: Baksmaling classes3.dex...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
I: Copying META-INF/services directory

Steps to Reproduce

  1. Download All 4 app from APKPure or any other source (https://m.apkpure.com/all-4-watch-live-on-demand/com.channel4.ondemand/download)
  2. Rename apk to All4.apk for ease
  3. Run java -jar apktool_2.7.0.jar decode All4.apk -o All4-decoded -only-main-classes
  4. Open decoded folder and open AndroidManifest.xml
  5. Observe that attributes are missing from certain tags

Screenshot 2023-01-18 at 16 06 45

Frameworks

N/A

APK

https://m.apkpure.com/all-4-watch-live-on-demand/com.channel4.ondemand/download

Questions to ask before submission

  1. Have you tried apktool d, apktool b without changing anything? Yes
  2. If you are trying to install a modified apk, did you resign it? N/A - Not an installation issue
  3. Are you using the latest apktool version? - Yes
@iBotPeaches
Copy link
Owner

Hmm that is odd. I replicate.

Marking as bug.

@mcirsta
Copy link

mcirsta commented Feb 9, 2023

I have exactly the same issue with one apk that I downloaded. Jadx seems to parse it correctly so it's somehow a problem in the parser I guess

@gustavi
Copy link

gustavi commented May 3, 2023

Hello, any news of this bug? Any idea where I can dig to fix it? It affects more and more APKs.

@gustavi
Copy link

gustavi commented May 3, 2023

After some research the bug was introduced by 3fff2f1.

@asafe199
Copy link

Hello, is there any updates?

@iBotPeaches
Copy link
Owner

PR linked above solves about 99% of this. Struggling to figure out a few resources.

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_enabled="true" app:2130969642="true" 2130969643="false">
        <objectAnimator android:duration="150" android:valueTo="0.0dip" android:valueType="floatType" android:propertyName="elevation" />
    </item>
    <item android:state_enabled="true">
        <objectAnimator android:duration="150" android:valueTo="4.0dip" android:valueType="floatType" android:propertyName="elevation" />
    </item>
    <item>
        <objectAnimator android:duration="0" android:valueTo="0" android:valueType="floatType" android:propertyName="elevation" />
    </item>
</selector>

This is file - res/animator/2130837531.xml or res/raw/J.xml (when its axml). You can tell we have 2 invalid properties that were not resolved into anything. This makes an invalid key because we fell back to it.

aapt2

➜  2981  aapt2 d xmltree 2981.apk --file res/raw/J.xml
N: app=http://schemas.android.com/apk/res-auto (line=0)
  N: android=http://schemas.android.com/apk/res/android (line=0)
    E: selector (line=0)
        E: item (line=0)
          A: (0x0101009e)=true
          A: (0x7f04042a)=true
          A: (0x7f04042b)=false

aapt

➜  2981  aapt d xmltree 2981.apk res/raw/J.xml
N: app=http://schemas.android.com/apk/res-auto
  N: android=http://schemas.android.com/apk/res/android
    E: selector (line=0)
      E: item (line=0)
        A: (0x0101009e)=(type 0x12)0xffffffff
        A: (0x7f04042a)=(type 0x12)0xffffffff
        A: (0x7f04042b)=(type 0x12)0x0

No matter what I search these appear to be invalid/bogus resources. They have no corresponding resource/name

➜  2981 aapt2 dump xmlstrings 2981.apk --file res/raw/J.xml           
String pool of 15 unique UTF-8 non-sorted strings, 15 entries and 0 styles using 296 bytes:
String #0 : 
String #1 : duration
String #2 : valueTo
String #3 : valueType
String #4 : propertyName
String #5 : 
String #6 : 

(the 2 missing xmlstrings)

➜  2981 aapt2 dump resources 2981.apk -v | grep '0x7f04042a' -A 3 -B 3
      () (attr) type=boolean
    resource 0x7f040429 attr/2130969641
      () (attr) type=boolean
    resource 0x7f04042a attr/2130969642
      () (attr) type=boolean
    resource 0x7f04042b attr/2130969643
      () (attr) type=boolean

(the resource dumped w/ name context)

iBotPeaches added a commit that referenced this issue Jul 4, 2023
@iBotPeaches iBotPeaches added this to the v2.8.0 milestone Jul 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants