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

Use aapt2 build apk failed #1776

Closed
chris-sharl opened this Issue Apr 23, 2018 · 13 comments

Comments

Projects
None yet
6 participants
@chris-sharl

chris-sharl commented Apr 23, 2018

Information

  1. Apktool Version (2.3.2)
  2. Operating System (Windows)
  3. APK From? (My Project)

Stacktrace/Logcat

April 23, 2018 3:59:29 下午 brut.androlib.Androlib build
Info: Using Apktool 2.3.2
April 23, 2018 3:59:29 下午 brut.androlib.Androlib buildSourcesRaw
Info: Copying ..\working\channels\vivo classes.dex file...
April 23, 2018 3:59:29 下午 brut.androlib.Androlib buildSourcesRaw
Info: Copying ..\working\channels\vivo classes2.dex file...
April 23, 2018 3:59:29 下午 brut.androlib.Androlib buildSourcesRaw
Info: Copying ..\working\channels\vivo classes3.dex file...
April 23, 2018 3:59:29 下午 brut.androlib.Androlib buildSourcesRaw
Info: Copying ..\working\channels\vivo classes4.dex file...
April 23, 2018 3:59:30 下午 brut.androlib.Androlib buildResourcesFull
Info: Checking whether resources has changed...
April 23, 2018 3:59:30 下午 brut.androlib.Androlib buildResourcesFull
Info: Building resources...
April 23, 2018 4:00:12 下午 java.util.logging.LogManager$RootLogger log
Warn: C:\workspace\git\mc\channel-builder\..\working\channels\vivo\res\values\public.xml:3959: error: resource 'drawable/$avd_hide_password__0' has invalid entry name '$avd_hide_password__0'. Invalid character '$avd_hide_password__0'.
April 23, 2018 4:00:12 下午 java.util.logging.LogManager$RootLogger log
Warn: C:\workspace\git\mc\channel-builder\..\working\channels\vivo\res\values\public.xml:3960: error: resource 'drawable/$avd_hide_password__1' has invalid entry name '$avd_hide_password__1'. Invalid character '$avd_hide_password__1'.
April 23, 2018 4:00:12 下午 java.util.logging.LogManager$RootLogger log
Warn: C:\workspace\git\mc\channel-builder\..\working\channels\vivo\res\values\public.xml:3961: error: resource 'drawable/$avd_hide_password__2' has invalid entry name '$avd_hide_password__2'. Invalid character '$avd_hide_password__2'.
April 23, 2018 4:00:12 下午 java.util.logging.LogManager$RootLogger log
Warn: C:\workspace\git\mc\channel-builder\..\working\channels\vivo\res\values\public.xml:3962: error: resource 'drawable/$avd_show_password__0' has invalid entry name '$avd_show_password__0'. Invalid character '$avd_show_password__0'.
April 23, 2018 4:00:12 下午 java.util.logging.LogManager$RootLogger log
Warn: C:\workspace\git\mc\channel-builder\..\working\channels\vivo\res\values\public.xml:3963: error: resource 'drawable/$avd_show_password__1' has invalid entry name '$avd_show_password__1'. Invalid character '$avd_show_password__1'.
April 23, 2018 4:00:12 下午 java.util.logging.LogManager$RootLogger log
Warn: C:\workspace\git\mc\channel-builder\..\working\channels\vivo\res\values\public.xml:3964: error: resource 'drawable/$avd_show_password__2' has invalid entry name '$avd_show_password__2'. Invalid character '$avd_show_password__2'.
brut.androlib.AndrolibException: brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [C:\tools\android-sdk\build-tools\27.0.1\aapt2.exe, compile, --dir, C:\workspace\git\mc\channel-builder\..\working\channels\vivo\res, --legacy, -o, C:\workspace\git\mc\channel-builder\..\working\channels\vivo\build\resources.zip]
	at brut.androlib.Androlib.buildResourcesFull(Androlib.java:503)
	at brut.androlib.Androlib.buildResources(Androlib.java:426)
	at brut.androlib.Androlib.build(Androlib.java:305)
	at brut.androlib.Androlib.build(Androlib.java:269)
	at cn.mc.tools.channel.Main.build(Main.java:219)
	at cn.mc.tools.channel.Main.buildApkPerChannel(Main.java:189)
	at cn.mc.tools.channel.Main.access$000(Main.java:34)
	at cn.mc.tools.channel.Main$1.run(Main.java:102)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [C:\tools\android-sdk\build-tools\27.0.1\aapt2.exe, compile, --dir, C:\workspace\git\mc\channel-builder\..\working\channels\vivo\res, --legacy, -o, C:\workspace\git\mc\channel-builder\..\working\channels\vivo\build\resources.zip]
	at brut.androlib.res.AndrolibResources.aapt2Package(AndrolibResources.java:358)
	at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:594)
	at brut.androlib.Androlib.buildResourcesFull(Androlib.java:481)
	... 10 more
Caused by: brut.common.BrutException: could not exec (exit code = 1): [C:\tools\android-sdk\build-tools\27.0.1\aapt2.exe, compile, --dir, C:\workspace\git\mc\channel-builder\..\working\channels\vivo\res, --legacy, -o, C:\workspace\git\mc\channel-builder\..\working\channels\vivo\build\resources.zip]
	at brut.util.OS.exec(OS.java:97)
	at brut.androlib.res.AndrolibResources.aapt2Package(AndrolibResources.java:354)
	... 12 more

Steps to Reproduce

  1. use ApkDecoder decode MyProject.apk
  2. build unsignedApkFile failed with the following code.
    private void build(File dir, File unsignedApkFile) throws BrutException {
        ApkOptions apkOptions = new ApkOptions();
        apkOptions.aaptPath = aaptPath;
        apkOptions.useAapt2 = true;
        apkOptions.aaptVersion = 2;
        apkOptions.forceDeleteFramework = true;
        new Androlib(apkOptions).build(dir, unsignedApkFile);
    }

@iBotPeaches
I don't know where is the source of the resource like $avd_hide_password__x.
I decode the apk file, and find them in the drawable-v21.

@chris-sharl

This comment has been minimized.

chris-sharl commented Apr 23, 2018

@iBotPeaches

This comment has been minimized.

Owner

iBotPeaches commented Apr 23, 2018

Thanks, seems we have some invalid characters to patch in.

Invalid character '$avd_hide_password__0'.
@edotassi

This comment has been minimized.

edotassi commented Apr 24, 2018

Same issue

@iamironz

This comment has been minimized.

iamironz commented Apr 27, 2018

Same problem

@ibuprophen1

This comment has been minimized.

ibuprophen1 commented Apr 27, 2018

@iamironz, you just stated "Same problem" but, this issue was regarding the use of Apktool v2.3.2 but, @iBotPeaches had just released v2.3.3 yesterday and can be located in the following area of Github.

https://github.com/iBotPeaches/Apktool/releases/tag/v2.3.3

If your having this same issue using v2.3.3, and everything else matches with what this issue was opened with, then @iBotPeaches really needs to know this as well.

Just an FYI in case you weren't aware of this... :-)

~Ibuprophen

@iamironz

This comment has been minimized.

iamironz commented Apr 28, 2018

@iBotPeaches cmon, in 2.3.3 release all release notes are release notes pending, users don't know about fixes in this release. Of course I can look into the commit diff but worth to provide release notes for any new artifacts.

@iBotPeaches

This comment has been minimized.

Owner

iBotPeaches commented May 2, 2018

@iamironz I sincerely apologize that my release notes in a blog post were not posted immediately. Unfortunately during my busy life of flying around the country, I forgot my Two Factor Auth device at home. I could not sign into my blog and make the post without it.

However, the release notes on this page: https://ibotpeaches.github.io/Apktool/changes/ have been up to date forever and never missing. So you could have always used that :)

@ibuprophen1 I generally will update bugs when I have fixed them. Sometimes bugs are fixed by me fixing a different one, but thats rare. This bug is still valid and will hopefully be fixed in next release.

@iBotPeaches

This comment has been minimized.

Owner

iBotPeaches commented May 2, 2018

Okay, I need to rebuild the aapt2 binaries for all 3 platforms, but the source fix in aapt2 has been made: iBotPeaches/platform_frameworks_base@ad643be

@ibuprophen1

This comment has been minimized.

ibuprophen1 commented May 2, 2018

@iBotPeaches, it looks like you had just changed it from returning a False (stopping) to ignoring it and just continue (keep going)...

I hope I had worded it okay via text... :-)

~Ibuprophen

@vkadam

This comment has been minimized.

vkadam commented May 3, 2018

@iBotPeaches how can I start using the commit you did on platform_frameworks_base?
Please ignore my stupidness, I am still newbie at apktool, so don't know all the setup required to use apktool from source.

@iamironz

This comment has been minimized.

iamironz commented May 3, 2018

@iBotPeaches thank you for explanation!

@iBotPeaches

This comment has been minimized.

@iBotPeaches

This comment has been minimized.

Owner

iBotPeaches commented Jun 11, 2018

Okay sorry for the delay. Lots of changes have gone "mainline" into "master" in AOSP. I don't see these changes tagged in the latest public release. (Nor any in the past 7 months).

This method of using tags for frameworks/base releases was dumb. We will use master and just tag the commit we used. I will have aapt1/aapt2 new binaries up this week

iBotPeaches added a commit that referenced this issue Jun 12, 2018

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