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

1px tall/wide 9patch images decoding fails. #1522

Closed
argraur opened this Issue Jun 1, 2017 · 41 comments

Comments

Projects
None yet
@argraur
Copy link

argraur commented Jun 1, 2017

Information

  1. apktool 2.2.3-dirty -
  2. Windows -
  3. Android O -

Stacktrace

PS E:\image-bullhead-opp2.170420.019\system_\priv-app\SystemUI> java -jar .\apktool-2.2.3-dirty-small.jar b .\SystemUI --no-src
I: Using Apktool 2.2.3-dirty
I: Checking whether sources has changed...
I: Checking whether resources has changed...
I: Building resources...
W: ERROR: 9-patch image E:\image-bullhead-opp2.170420.019\system_\priv-app\SystemUI\.\SystemUI\res\drawable-xxhdpi\pip_dismiss_scrim.9.png malformed.
W:        No marked region found along edge.
W:        Found along left edge.
W: ERROR: Failure processing PNG image E:\image-bullhead-opp2.170420.019\system_\priv-app\SystemUI\.\SystemUI\res\drawable-xxhdpi\pip_dismiss_scrim.9.png
Exception in thread "main" brut.androlib.AndrolibException: brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\8523~1\AppData\Local\Temp\brut_util_Jar_6815133651981008170.tmp, p, --forced-package-id, 127, --min-sdk-version, O, --target-sdk-version, O, --version-code, 25, --version-name, O, --no-version-vectors, -F, C:\Users\8523~1\AppData\Local\Temp\APKTOOL1879548677653248317.tmp, -0, arsc, -0, arsc, -I, C:\Users\Александр\AppData\Local\apktool\framework\1.apk, -S, E:\image-bullhead-opp2.170420.019\system_\priv-app\SystemUI\.\SystemUI\res, -M, E:\image-bullhead-opp2.170420.019\system_\priv-app\SystemUI\.\SystemUI\AndroidManifest.xml]
        at brut.androlib.Androlib.buildResourcesFull(Androlib.java:493)
        at brut.androlib.Androlib.buildResources(Androlib.java:427)
        at brut.androlib.Androlib.build(Androlib.java:326)
        at brut.androlib.Androlib.build(Androlib.java:264)
        at brut.apktool.Main.cmdBuild(Main.java:231)
        at brut.apktool.Main.main(Main.java:84)
Caused by: brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\8523~1\AppData\Local\Temp\brut_util_Jar_6815133651981008170.tmp, p, --forced-package-id, 127, --min-sdk-version, O, --target-sdk-version, O, --version-code, 25, --version-name, O, --no-version-vectors, -F, C:\Users\8523~1\AppData\Local\Temp\APKTOOL1879548677653248317.tmp, -0, arsc, -0, arsc, -I, C:\Users\Александр\AppData\Local\apktool\framework\1.apk, -S, E:\image-bullhead-opp2.170420.019\system_\priv-app\SystemUI\.\SystemUI\res, -M, E:\image-bullhead-opp2.170420.019\system_\priv-app\SystemUI\.\SystemUI\AndroidManifest.xml]
        at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:441)
        at brut.androlib.Androlib.buildResourcesFull(Androlib.java:479)
        ... 5 more
Caused by: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\8523~1\AppData\Local\Temp\brut_util_Jar_6815133651981008170.tmp, p, --forced-package-id, 127, --min-sdk-version, O, --target-sdk-version, O, --version-code, 25, --version-name, O, --no-version-vectors, -F, C:\Users\8523~1\AppData\Local\Temp\APKTOOL1879548677653248317.tmp, -0, arsc, -0, arsc, -I, C:\Users\Александр\AppData\Local\apktool\framework\1.apk, -S, E:\image-bullhead-opp2.170420.019\system_\priv-app\SystemUI\.\SystemUI\res, -M, E:\image-bullhead-opp2.170420.019\system_\priv-app\SystemUI\.\SystemUI\AndroidManifest.xml]
        at brut.util.OS.exec(OS.java:95)
        at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:435)
        ... 6 more

Steps to Reproduce

  1. java -jar apktool-2.2.3-dirty-small.jar b SystemUI --no-src

APK

GDrive

Questions to ask before submission

  1. Yeah
  2. Yes
@argraur

This comment has been minimized.

Copy link
Author

argraur commented Jun 1, 2017

Yeah it's me again, and I have one more issue :(

@iBotPeaches

This comment has been minimized.

Copy link
Owner

iBotPeaches commented Jun 1, 2017

Please try reverting this commit - 6e47d36 and let me know if the problem persists.

@argraur

This comment has been minimized.

Copy link
Author

argraur commented Jun 1, 2017

Sure

@argraur

This comment has been minimized.

Copy link
Author

argraur commented Jun 1, 2017

Hmm can't revert commit.
Shows error:
error: commit 6e47d36 - commit-merge, but -m option is not defined.

@iBotPeaches

This comment has been minimized.

Copy link
Owner

iBotPeaches commented Jun 1, 2017

Revert this a00da34

then this dd32f94

@argraur

This comment has been minimized.

Copy link
Author

argraur commented Jun 1, 2017

still cant revert that commit
error: commit 6e47d36 is a merge but no -m option was given.
fatal: revert failed

@iBotPeaches

This comment has been minimized.

Copy link
Owner

iBotPeaches commented Jun 1, 2017

Okay just hold then. I won't have time till the weekend to investigate.

@argraur

This comment has been minimized.

Copy link
Author

argraur commented Jun 1, 2017

Finally I reverted that commit by git rebase -i.
And after test, It's failed again.

I: Using Apktool 2.2.3-1f1758-SNAPSHOT
W: Could not find sources
I: Checking whether resources has changed...
I: Building resources...
W: ERROR: 9-patch image /home/argraur/working_directoru/sign_o/SystemUI/res/drawable-xxhdpi/pip_dismiss_scrim.9.png malformed.
W:        No marked region found along edge.
W:        Found along left edge.
W: ERROR: Failure processing PNG image /home/argraur/working_directoru/sign_o/SystemUI/res/drawable-xxhdpi/pip_dismiss_scrim.9.png
Exception in thread "main" brut.androlib.AndrolibException: brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/tmp/brut_util_Jar_5128022422052930085.tmp, p, --forced-package-id, 127, --min-sdk-version, O, --target-sdk-version, O, --version-code, 25, --version-name, O, --no-version-vectors, -F, /tmp/APKTOOL7440049650671455157.tmp, -0, arsc, -0, arsc, -I, /root/.local/share/apktool/framework/1.apk, -S, /home/argraur/working_directoru/sign_o/SystemUI/res, -M, /home/argraur/working_directoru/sign_o/SystemUI/AndroidManifest.xml]
        at brut.androlib.Androlib.buildResourcesFull(Androlib.java:493)
        at brut.androlib.Androlib.buildResources(Androlib.java:427)
        at brut.androlib.Androlib.build(Androlib.java:326)
        at brut.androlib.Androlib.build(Androlib.java:264)
        at brut.apktool.Main.cmdBuild(Main.java:231)
        at brut.apktool.Main.main(Main.java:84)
Caused by: brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/tmp/brut_util_Jar_5128022422052930085.tmp, p, --forced-package-id, 127, --min-sdk-version, O, --target-sdk-version, O, --version-code, 25, --version-name, O, --no-version-vectors, -F, /tmp/APKTOOL7440049650671455157.tmp, -0, arsc, -0, arsc, -I, /root/.local/share/apktool/framework/1.apk, -S, /home/argraur/working_directoru/sign_o/SystemUI/res, -M, /home/argraur/working_directoru/sign_o/SystemUI/AndroidManifest.xml]
        at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:441)
        at brut.androlib.Androlib.buildResourcesFull(Androlib.java:479)
        ... 5 more
Caused by: brut.common.BrutException: could not exec (exit code = 1): [/tmp/brut_util_Jar_5128022422052930085.tmp, p, --forced-package-id, 127, --min-sdk-version, O, --target-sdk-version, O, --version-code, 25, --version-name, O, --no-version-vectors, -F, /tmp/APKTOOL7440049650671455157.tmp, -0, arsc, -0, arsc, -I, /root/.local/share/apktool/framework/1.apk, -S, /home/argraur/working_directoru/sign_o/SystemUI/res, -M, /home/argraur/working_directoru/sign_o/SystemUI/AndroidManifest.xml]
        at brut.util.OS.exec(OS.java:95)
        at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:435)
        ... 6 more
@argraur

This comment has been minimized.

Copy link
Author

argraur commented Jun 9, 2017

?

@iBotPeaches

This comment has been minimized.

Copy link
Owner

iBotPeaches commented Jun 9, 2017

This 9patch image is a 1px wide image which I've never seen before.

https://github.com/android/platform_frameworks_base/blob/master/libs/androidfw/include/androidfw/ResourceTypes.h#L53

https://stackoverflow.com/questions/23858098/nine-patch-images-with-1px-width-or-height-special-case-or-faulty-files

However, it reports only 1 patch data blob that is 1 pixel long, which you can see from the below image is inserted in between the 3 pixel wide image. (The size grew from 1px to 3px due to adding 2 pixel for 9patch data)

screenshot from 2017-06-09 08-25-26

Since this is affecting only 1px wide/tall images, I'm hesitant to spend any more time on this besides the initial research. It is confirmed, so any additional research or PRs are accepted.

@iBotPeaches iBotPeaches changed the title 9-patch image malformed. No marked region found along edge. Found along left edge. 1px tall/wide 9patch images decoding fails. Jun 9, 2017

@iBotPeaches iBotPeaches removed the Accepted label Jun 23, 2017

@argraur

This comment has been minimized.

Copy link
Author

argraur commented Jul 26, 2017

Why you don't want to fix it? This issue appears with SystemUI on stock Android O DP4 only, so it is Android O issue. This bug stops my ROM development

@iBotPeaches

This comment has been minimized.

Copy link
Owner

iBotPeaches commented Jul 26, 2017

I never said that. I said, "I'm hesitant". This is a 1 pixel image in which we have to insert 9patch data which is very time consuming and I don't yet truly understand when it comes to 1 pixel images.

Read this 3-4 paragraph doc block about the encoded 9patch data - https://github.com/android/platform_frameworks_base/blob/master/libs/androidfw/include/androidfw/ResourceTypes.h#L53

Then apply that to a 1 pixel wide image.

@charlescl

This comment has been minimized.

Copy link

charlescl commented Jul 28, 2017

Just test the 2.2.4 self-build, can build the systemUI.apk DP4 after patch the 1px png with draw9patch.jar, but the re-builded systemUI.apk did not work.

@churchmice

This comment has been minimized.

Copy link

churchmice commented Sep 29, 2017

@charlescl could you share your self-built apktool ?

@iBotPeaches

This comment has been minimized.

Copy link
Owner

iBotPeaches commented Sep 29, 2017

@charlescl 2.2.4 (renamed to 2.3.0) was officially released a few days ago. There would be no gain using a custom old build of 2.2.4.

@churchmice

This comment has been minimized.

Copy link

churchmice commented Sep 30, 2017

@iBotPeaches Great, but I tried the 2.2.4 and 2.3.0 and still got the 'No marked region found along edge' error when trying to recompile SystemUIGoogle.apk without modification.

@syrm

This comment has been minimized.

Copy link

syrm commented Dec 19, 2017

So far there is no solution ?

@iBotPeaches

This comment has been minimized.

Copy link
Owner

iBotPeaches commented Dec 20, 2017

@syrm Fix the affected images so they are proper 9patch images is a temporary solution. If you have the time you can jump into Apktool's 9Patch decoder and investigate if we are making any incorrect assumptions decoding these images.

@AncalagonTheBlack

This comment has been minimized.

Copy link

AncalagonTheBlack commented Jul 16, 2018

How can i fix the images i tried to resave them with the 9patch.jar but it still throws the same error above at me. im using an oreo rom (resurection remix) and i have no idea how get this one stupid image to compile.

@Mi2Sir

This comment has been minimized.

Copy link

Mi2Sir commented Aug 2, 2018

I meet the same 9patch malformed error.
Is there any solution?

@exelix11

This comment has been minimized.

Copy link

exelix11 commented Aug 3, 2018

@Mi2Sir I've been stuck with this error for a few hours with pip_dismiss_scrim.9.png to fix it I just manually added the marker with an image editor. Don't use mspaint or any other tool that discards alpha.
I had the same image iBotPeaches posted, a line was clearly missing on the left side

@daduke

This comment has been minimized.

Copy link

daduke commented Aug 6, 2018

you just added a vertical white line in the first column? I tried that but still get the error.

@exelix11

This comment has been minimized.

Copy link

exelix11 commented Aug 6, 2018

Leave the first and last pixels blank, if you have the same image just copy the right pixel column into the left, that did the trick for me.
Still I can't get my patched SystemUI to work, it crashes every time, don't know if it's because of this or i'm missing some steps

@daduke

This comment has been minimized.

Copy link

daduke commented Aug 6, 2018

thanks! This part worked, now I'm having new issues...

@daduke

This comment has been minimized.

Copy link

daduke commented Aug 7, 2018

same here now: modded SystemUI crashes, log doesn't help much.

@daduke

This comment has been minimized.

Copy link

daduke commented Aug 17, 2018

@exelix11 did you ever manage to compile a working SystemUI?

@exelix11

This comment has been minimized.

Copy link

exelix11 commented Aug 17, 2018

Unfortunately no,every time I flash my build with magisk the notifications bar and task switcher stop working, and when I remove it from magisk I get a bootloop with systemUI has stopped, restoring a data backup fixes it. I just got back on Android modding probably there is something I'm missing (odex maybe?)

@daduke

This comment has been minimized.

Copy link

daduke commented Aug 17, 2018

same here.. I tried the 'copy META-INF and AndroidManifest.xml from original apk' that everybody mentions + zipalign but it just keeps crashing sigh

@exelix11

This comment has been minimized.

Copy link

exelix11 commented Aug 17, 2018

Yeah tried that as well, still no luck

@alexschenider

This comment has been minimized.

Copy link

alexschenider commented Aug 24, 2018

So there is a solution or not? 2 days I was stranded and didn't find any solution.

@AncalagonTheBlack

This comment has been minimized.

Copy link

AncalagonTheBlack commented Aug 24, 2018

i gave up on it. i did it the dirty way. i unpacked the apk created a zip archive and changed the extension to apk. its not optimal but its working.

@exelix11

This comment has been minimized.

Copy link

exelix11 commented Aug 24, 2018

Unfortunately it's not possible to edit all of the resources this way

@587saboor

This comment has been minimized.

Copy link

587saboor commented Aug 30, 2018

I have this problem too, anyone have a temporary solution for this?
EDIT: i found the fix, nvm

@exelix11

This comment has been minimized.

Copy link

exelix11 commented Sep 19, 2018

Ok so, i couldn't get apktool to patch my systemUI so i made an Xposed module to change what i needed and it's working like a charm. Maybe it's not the optimal solution for everyone but it's ok for me and wasn't even that hard to get it working, so if you're still stuck on this give Xposed a try

@lastant

This comment has been minimized.

Copy link

lastant commented Dec 9, 2018

I have this problem too, anyone have a temporary solution for this?
EDIT: i found the fix, nvm

How did you manage to fix this?

@jkryanchou

This comment has been minimized.

Copy link

jkryanchou commented Feb 14, 2019

Is there any solution on the issue. I have tried on apktool 2.3.4, it doesn't work well yet. Raise same issue as issuer mention.

@iBotPeaches

This comment has been minimized.

Copy link
Owner

iBotPeaches commented Feb 14, 2019

There is a solution (by @IgorEisberg) in review right now. - 132a370

Been busy.

@jkryanchou

This comment has been minimized.

Copy link

jkryanchou commented Feb 14, 2019

@iBotPeaches I have searched for the same issue. and found the solution from the issue #2001, While I rebuild with --use-aapt2 It raised another issue as below.

.... res/values/ids.xml:3: error: <item> inner element must either be a resource reference or empty.
.... res/values/ids.xml:4: error: <item> inner element must either be a resource reference or empty.
.... res/values/ids.xml:5: error: <item> inner element must either be a resource reference or empty.
@jkryanchou

This comment has been minimized.

Copy link

jkryanchou commented Feb 14, 2019

@iBotPeaches When the latest version could be released?

@iBotPeaches

This comment has been minimized.

Copy link
Owner

iBotPeaches commented Feb 14, 2019

I'm already 4 months behind. Windows builds are broken and I have a stack (2) of pending PRs to merge and a backlog that grows daily. I am hoping to find some weekend time to handle this.

@jkryanchou

This comment has been minimized.

Copy link

jkryanchou commented Feb 15, 2019

@iBotPeaches OK, Got it. Wish it release soon.

iBotPeaches added a commit that referenced this issue Feb 18, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.