Apktool: Use aapt2 build apk failed
Information
- Apktool Version (
2.3.2
) - Operating System (Windows)
- 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
- use ApkDecoder decode MyProject.apk
- 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.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 3
- Comments: 32 (8 by maintainers)
Commits related to this issue
- docs: split aapt1/aapt2 base AOSP build — committed to iBotPeaches/Apktool by iBotPeaches 6 years ago
- update changelog for #1776 — committed to iBotPeaches/Apktool by iBotPeaches 6 years ago
I still encouter this ploblem with 2.40 on win10 64bit Pro.
java -jar apktool_2.4.0_.jar b “Locus” -use-aapt2 -f -o 1.apk I: Using Apktool 2.4.0 I: Smaling smali folder into classes.dex… I: Smaling smali_classes2 folder into classes2.dex… I: Smaling smali_classes3 folder into classes3.dex… I: Building resources… W: E:\test\locus\tmp\Locus\res\values\public.xml:1436: error: resource ‘drawable/$ic_locoin__0’ has invalid entry name ‘$ic_locoin__0’. Invalid character ‘$ic_locoin__0’. W: E:\test\locus\tmp\Locus\res\values\public.xml:1437: error: resource ‘drawable/$ic_locoin__1’ has invalid entry name ‘$ic_locoin__1’. Invalid character ‘$ic_locoin__1’. W: E:\test\locus\tmp\Locus\res\values\public.xml:1438: error: resource ‘drawable/$ic_social_google__0’ has invalid entry name ‘$ic_social_google__0’. Invalid character ‘$ic_social_google__0’. W: E:\test\locus\tmp\Locus\res\values\public.xml:2084: error: resource ‘drawable/$avd_hide_password__0’ has invalid entry name ‘$avd_hide_password__0’. Invalid character ‘$avd_hide_password__0’. W: E:\test\locus\tmp\Locus\res\values\public.xml:2085: error: resource ‘drawable/$avd_hide_password__1’ has invalid entry name ‘$avd_hide_password__1’. Invalid character ‘$avd_hide_password__1’. W: E:\test\locus\tmp\Locus\res\values\public.xml:2086: error: resource ‘drawable/$avd_hide_password__2’ has invalid entry name ‘$avd_hide_password__2’. Invalid character ‘$avd_hide_password__2’. W: E:\test\locus\tmp\Locus\res\values\public.xml:2087: error: resource ‘drawable/$avd_ic_eye_hide_to_visible__0’ has invalid entry name ‘$avd_ic_eye_hide_to_visible__0’. Invalid character ‘$avd_ic_eye_hide_to_visible__0’. W: E:\test\locus\tmp\Locus\res\values\public.xml:2088: error: resource ‘drawable/$avd_ic_eye_hide_to_visible__1’ has invalid entry name ‘$avd_ic_eye_hide_to_visible__1’. Invalid character ‘$avd_ic_eye_hide_to_visible__1’. W: E:\test\locus\tmp\Locus\res\values\public.xml:2089: error: resource ‘drawable/$avd_ic_eye_hide_to_visible__2’ has invalid entry name ‘$avd_ic_eye_hide_to_visible__2’. Invalid character ‘$avd_ic_eye_hide_to_visible__2’. W: E:\test\locus\tmp\Locus\res\values\public.xml:2090: error: resource ‘drawable/$avd_ic_eye_visible_to_hide__0’ has invalid entry name ‘$avd_ic_eye_visible_to_hide__0’. Invalid character ‘$avd_ic_eye_visible_to_hide__0’. W: E:\test\locus\tmp\Locus\res\values\public.xml:2091: error: resource ‘drawable/$avd_ic_eye_visible_to_hide__1’ has invalid entry name ‘$avd_ic_eye_visible_to_hide__1’. Invalid character ‘$avd_ic_eye_visible_to_hide__1’. W: E:\test\locus\tmp\Locus\res\values\public.xml:2092: error: resource ‘drawable/$avd_ic_eye_visible_to_hide__2’ has invalid entry name ‘$avd_ic_eye_visible_to_hide__2’. Invalid character ‘$avd_ic_eye_visible_to_hide__2’. W: E:\test\locus\tmp\Locus\res\values\public.xml:2093: error: resource ‘drawable/$avd_show_password__0’ has invalid entry name ‘$avd_show_password__0’. Invalid character ‘$avd_show_password__0’. W: E:\test\locus\tmp\Locus\res\values\public.xml:2094: error: resource ‘drawable/$avd_show_password__1’ has invalid entry name ‘$avd_show_password__1’. Invalid character ‘$avd_show_password__1’. W: E:\test\locus\tmp\Locus\res\values\public.xml:2095: error: resource ‘drawable/$avd_show_password__2’ has invalid entry name ‘$avd_show_password__2’. Invalid character ‘$avd_show_password__2’. I: Copying libs… (/lib) I: Copying libs… (/kotlin) I: Building apk file… I: Copying unknown files/dir… I: Built apk…
at last I get 1.apk, but the 1.apk crashed when launch after installed. and the apk name and icon displayed on the screen are wrong.
but I can build the apk with aapt1.
@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.
Okay, I need to rebuild the aapt2 binaries for all 3 platforms, but the source fix in aapt2 has been made: https://github.com/iBotPeaches/platform_frameworks_base/commit/ad643be8174e740124b4bc59e4cc1e70541f6a4e
@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
Same issue with 2.4.1. Anybody has a fix?
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
@vkadam Documented here: https://github.com/iBotPeaches/Apktool/blob/master/INTERNAL.md#first-we-need-the-aosp-source
@iBotPeaches thank you for explanation!
@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
@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.Same problem