Apktool icon indicating copy to clipboard operation
Apktool copied to clipboard

Use aapt2 build apk failed

Open chris-sharl opened this issue 8 years ago • 32 comments

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 avatar Apr 23 '18 08:04 chris-sharl

@iBotPeaches

chris-sharl avatar Apr 23 '18 08:04 chris-sharl

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

Invalid character '$avd_hide_password__0'.

iBotPeaches avatar Apr 23 '18 17:04 iBotPeaches

Same issue

edotassi avatar Apr 24 '18 21:04 edotassi

Same problem

iamironz avatar Apr 27 '18 11:04 iamironz

@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

Ibuprophen avatar Apr 27 '18 15:04 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.

iamironz avatar Apr 28 '18 09:04 iamironz

@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 avatar May 02 '18 15:05 iBotPeaches

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

iBotPeaches avatar May 02 '18 19:05 iBotPeaches

@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

Ibuprophen avatar May 02 '18 20:05 Ibuprophen

@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.

vkadam avatar May 03 '18 04:05 vkadam

@iBotPeaches thank you for explanation!

iamironz avatar May 03 '18 10:05 iamironz

@vkadam Documented here: https://github.com/iBotPeaches/Apktool/blob/master/INTERNAL.md#first-we-need-the-aosp-source

iBotPeaches avatar May 03 '18 13:05 iBotPeaches

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 avatar Jun 11 '18 16:06 iBotPeaches

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.

eriklu avatar Jun 17 '19 02:06 eriklu

i have the same problem using 2.4.0

ahmadii avatar Oct 31 '19 08:10 ahmadii

I have the same problem using 2.4.1

JerryZhu86 avatar Mar 09 '20 15:03 JerryZhu86

Same issue with 2.4.1. Anybody has a fix?

cents02 avatar Mar 13 '20 14:03 cents02

I also need a fix for this. if anyone has one let me know

Allevon412 avatar Apr 06 '20 19:04 Allevon412

Have the same problem using 2.4.1 Actually I can build the apk normally but it can not launch normally... Let me know if anyone can solve it

iTruth avatar May 07 '20 08:05 iTruth

Hi I am also having the same issue . Version used :-- 2.4.1 @iBotPeaches please help thanks

sillydadddy avatar May 15 '20 20:05 sillydadddy