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

Apk build fails if use aapt2 option is ON with latest ApkTool (2.4.1) #2386

Closed
vramasam opened this issue Aug 4, 2020 · 13 comments · Fixed by #2370
Closed

Apk build fails if use aapt2 option is ON with latest ApkTool (2.4.1) #2386

vramasam opened this issue Aug 4, 2020 · 13 comments · Fixed by #2370

Comments

@vramasam
Copy link

vramasam commented Aug 4, 2020

  1. Apktool Version 2.4.1
  2. Operating System MAC
  3. APK From? (My Project)

Stacktrace/Logcat

W: res/values/public.xml:1012: error: resource 'drawable/$avd_hide_password__0' has invalid entry name '$avd_hide_password__0'. Invalid character '$avd_hide_password__0'.
W: res/values/public.xml:1013: error: resource 'drawable/$avd_hide_password__1' has invalid entry name '$avd_hide_password__1'. Invalid character '$avd_hide_password__1'.
W: res/values/public.xml:1014: error: resource 'drawable/$avd_hide_password__2' has invalid entry name '$avd_hide_password__2'. Invalid character '$avd_hide_password__2'.
W: res/values/public.xml:1015: error: resource 'drawable/$avd_show_password__0' has invalid entry name '$avd_show_password__0'. Invalid character '$avd_show_password__0'.
W: res/values/public.xml:1016: error: resource 'drawable/$avd_show_password__1' has invalid entry name '$avd_show_password__1'. Invalid character '$avd_show_password__1'.
W: res/values/public.xml:1017: error: resource 'drawable/$avd_show_password__2' has invalid entry name '$avd_show_password__2'. Invalid character '$avd_show_password__2'.
W: res/values/public.xml: error: file failed to compile.
brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1):

Steps to Reproduce
Build apk using latest apktool version (2.4.1)

I saw this issue got fixed in 2.3.4 version in #1776 , But above issue is still happening. #2119
#2356 not able to get much information.

Can you please guide here

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? YES
  3. Are you using the latest apktool version? YES
@giacomoferretti
Copy link
Contributor

Using the new binaries in #2370 seems to fix this problem.
Tested with Apktool 2.4.2 built from source on Linux.

@vramasam
Copy link
Author

vramasam commented Aug 6, 2020

Thank you for the reply @giacomoferretti

Then in the upcoming 2.4.2 release ( https://ibotpeaches.github.io/Apktool/changes/ ). We will get fix for this issue isnt it?

@Surendrajat
Copy link

@vramasam Yes but the macOS binaries are still not ready so unless you are using macOS, you can simply pull that PR and build apktool yourself.

@vramasam
Copy link
Author

vramasam commented Aug 6, 2020

@vramasam Yes but the macOS binaries are still not ready so unless you are using macOS, you can simply pull that PR and build apktool yourself.

Thanks @Surendrajat for the suggestion. Can we follow this link for build https://ibotpeaches.github.io/Apktool/build/ ? Is there any specific things we need to take care for aapt2 build ?

@giacomoferretti
Copy link
Contributor

giacomoferretti commented Aug 6, 2020

That guide will only help you the APK took jar, and not the aapt2 binary. You should check https://github.com/iBotPeaches/Apktool/blob/master/INTERNAL.md#building-aapt-binaries

@vramasam vramasam closed this as completed Aug 6, 2020
@vramasam vramasam reopened this Aug 6, 2020
@vramasam
Copy link
Author

vramasam commented Aug 7, 2020

@giacomoferretti @Surendrajat
I have tried with aapt2 present in this PR in the linux machine.
Command used compile the apk:
ProcessBuilder processBuilder = new ProcessBuilder(
apktoolPath, "b", "-a", aaptFilePath,
directory, "-o", outputApkPath);

I am seeing the following errors, still:
W: decompiled/res/values/public.xml:945: error: resource 'drawable/$avd_hide_password__0' has invalid entry name '$avd_hide_password__0'. Invalid character '$avd_hide_password__0'.
W: decompiled/res/values/public.xml:946: error: resource 'drawable/$avd_hide_password__1' has invalid entry name '$avd_hide_password__1'. Invalid character '$avd_hide_password__1'.
W: decompiled/res/values/public.xml:947: error: resource 'drawable/$avd_hide_password__2' has invalid entry name '$avd_hide_password__2'. Invalid character '$avd_hide_password__2'.
W: decompiled/res/values/public.xml:948: error: resource 'drawable/$avd_show_password__0' has invalid entry name '$avd_show_password__0'. Invalid character '$avd_show_password__0'.
W: decompiled/res/values/public.xml:949: error: resource 'drawable/$avd_show_password__1' has invalid entry name '$avd_show_password__1'. Invalid character '$avd_show_password__1'.
W: decompiled/res/values/public.xml:950: error: resource 'drawable/$avd_show_password__2' has invalid entry name '$avd_show_password__2'. Invalid character '$avd_show_password__2'.
W: aapt2 W 08-07 10:00:22 1918 1918 ApkAssets.cpp:140] resources.arsc in APK '/home/jenkins/.local/share/apktool/framework/1.apk' is compressed.
W: decompiled/res/values/styles.xml:1237: error: resource 'style/TextAppearance.AppCompat' has a conflicting value for configuration ().
W: decompiled/res/values/styles.xml:4: note: originally defined here.
W: decompiled/res/values/styles.xml:1435: error: resource 'style/Theme.AppCompat' has a conflicting value for configuration ().
W: decompiled/res/values/styles.xml:15: note: originally defined here.
W: decompiled/build/resources.zip@values_styles.arsc.flat: error: failed to merge resource table.
W: error: failed parsing input.
brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): /aapt2, link, -o, /tmp/APKTOOL754004093322537751.tmp, --package-id, 127, --min-sdk-version, 27, --target-sdk-version, 30, --version-code, 5, --version-name, 5.0, --no-auto-version, --no-version-vectors, --no-version-transitions, --no-resource-deduping, -0, resources.arsc, -0, META-INF/android.arch.core_runtime.version, -0, META-INF/android.arch.lifecycle_livedata-core.version, -0, META-INF/android.arch.lifecycle_livedata.version, -0, META-INF/android.arch.lifecycle_runtime.version, -0, META-INF/android.arch.lifecycle_viewmodel.version, -0, META-INF/android.support.design_material.version, -0, META-INF/androidx.appcompat_appcompat.version, -0, META-INF/androidx.asynclayoutinflater_asynclayoutinflater.version, -0, META-INF/androidx.cardview_cardview.version, -0, META-INF/androidx.coordinatorlayout_coordinatorlayout.version, -0, META-INF/androidx.core_core.version, -0, META-INF/androidx.cursoradapter_cursoradapter.version, -0, META-INF/androidx.customview_customview.version, -0, META-INF/androidx.documentfile_documentfile.version, -0, META-INF/androidx.drawerlayout_drawerlayout.version, -0, META-INF/androidx.fragment_fragment.version, -0, META-INF/androidx.interpolator_interpolator.version, -0, META-INF/androidx.legacy_legacy-support-core-ui.version, -0, META-INF/androidx.legacy_legacy-support-core-utils.version, -0, META-INF/androidx.loader_loader.version, -0, META-INF/androidx.localbroadcastmanager_localbroadcastmanager.version, -0, META-INF/androidx.print_print.version, -0, META-INF/androidx.recyclerview_recyclerview.version, -0, META-INF/androidx.slidingpanelayout_slidingpanelayout.version, -0, META-INF/androidx.swiperefreshlayout_swiperefreshlayout.version, -0, META-INF/androidx.transition_transition.version, -0, META-INF/androidx.vectordrawable_vectordrawable-animated.version, -0, META-INF/androidx.vectordrawable_vectordrawable.version, -0, META-INF/androidx.versionedparcelable_versionedparcelable.version, -0, META-INF/androidx.viewpager_viewpager.version, -0, META-INF/com.google.android.material_material.version, -0, jpg, -0, mp3, -0, mp4, -0, png, -0, arsc, -I, /home/jenkins/.local/share/apktool/framework/1.apk, --manifest, /decompiled/build/resources.zip]

@shin-illua
Copy link

I have opened apktool_2.4.1.jar on Winrar, then went to prebuilt/windows, then I have replaced aapt2.exe with https://github.com/iBotPeaches/Apktool/blob/e6b18d24f5835aca09ecd40e88ef06450a95b99d/brut.apktool/apktool-lib/src/main/resources/prebuilt/windows/aapt2.exe and replace aapt2_x64.exe with https://github.com/iBotPeaches/Apktool/blob/e6b18d24f5835aca09ecd40e88ef06450a95b99d/brut.apktool/apktool-lib/src/main/resources/prebuilt/windows/aapt_64.exe (both link to the files I got from https://github.com/iBotPeaches/Apktool/pull/2370/files).

I don't know if what I even did was right, but it still gave me the same error, so anyone could prolly help?

@iBotPeaches
Copy link
Owner

I'm going to close with merge of #2370 even though I can't replicate this at all.

I just even wrote a bunch more aapt2 tests 3ac7e80 and assertions to be 100% sure I wasn't making a mistake and everything passed....

Sorry folks. I can't replicate any of these issues. You are welcome to jump into the code if you want and push forward a fix if you stumble upon anything, but after that merge. I'll consider this resolved.

@cryptax
Copy link

cryptax commented Sep 17, 2020

FYI, I had the same issue with apktool, and solved it by building apktool from sources. Solved the problem.

@ricsirigu
Copy link

ricsirigu commented Oct 18, 2020

  1. Apktool Version 2.4.1
  2. Operating System MAC
  3. APK From? (My Project)

Stacktrace/Logcat

W: res/values/public.xml:1012: error: resource 'drawable/$avd_hide_password__0' has invalid entry name '$avd_hide_password__0'. Invalid character '$avd_hide_password__0'.
W: res/values/public.xml:1013: error: resource 'drawable/$avd_hide_password__1' has invalid entry name '$avd_hide_password__1'. Invalid character '$avd_hide_password__1'.
W: res/values/public.xml:1014: error: resource 'drawable/$avd_hide_password__2' has invalid entry name '$avd_hide_password__2'. Invalid character '$avd_hide_password__2'.
W: res/values/public.xml:1015: error: resource 'drawable/$avd_show_password__0' has invalid entry name '$avd_show_password__0'. Invalid character '$avd_show_password__0'.
W: res/values/public.xml:1016: error: resource 'drawable/$avd_show_password__1' has invalid entry name '$avd_show_password__1'. Invalid character '$avd_show_password__1'.
W: res/values/public.xml:1017: error: resource 'drawable/$avd_show_password__2' has invalid entry name '$avd_show_password__2'. Invalid character '$avd_show_password__2'.
W: res/values/public.xml: error: file failed to compile.
brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1):

Steps to Reproduce
Build apk using latest apktool version (2.4.1)

I saw this issue got fixed in 2.3.4 version in #1776 , But above issue is still happening. #2119
#2356 not able to get much information.

Can you please guide here

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? YES
  3. Are you using the latest apktool version? YES

Same error building from source. Version 2.4.2-a2a794-SNAPSHOT

The error is the following

$ /usr/bin/java -Xmx256m -jar /usr/local/bin/apktool.jar b /base.apk-decompiled --use-aapt2
I: Using Apktool 2.4.2-a2a794-SNAPSHOT
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes2 folder into classes2.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes3 folder into classes3.dex...
I: Checking whether resources has changed...
I: Building resources...
W: /base.apk-decompiled/res/values/public.xml:2893: error: resource 'drawable/$animated_record_action__0' has invalid entry name '$animated_record_action__0'. Invalid character '$animated_record_action__0'.
W: /base.apk-decompiled/res/values/public.xml:2894: error: resource 'drawable/$animated_record_action__1' has invalid entry name '$animated_record_action__1'. Invalid character '$animated_record_action__1'.
W: /base.apk-decompiled/res/values/public.xml:2895: error: resource 'drawable/$animated_record_action_reverse__0' has invalid entry name '$animated_record_action_reverse__0'. Invalid character '$animated_record_action_reverse__0'.
W: /base.apk-decompiled/res/values/public.xml:2896: error: resource 'drawable/$animated_record_action_reverse__1' has invalid entry name '$animated_record_action_reverse__1'. Invalid character '$animated_record_action_reverse__1'.
W: /base.apk-decompiled/res/values/public.xml:2897: error: resource 'drawable/$animated_record_indicator__0' has invalid entry name '$animated_record_indicator__0'. Invalid character '$animated_record_indicator__0'.
W: /base.apk-decompiled/res/values/public.xml:2898: error: resource 'drawable/$animated_record_indicator__1' has invalid entry name '$animated_record_indicator__1'. Invalid character '$animated_record_indicator__1'.
W: /base.apk-decompiled/res/values/public.xml:2899: error: resource 'drawable/$avd_hide_password__0' has invalid entry name '$avd_hide_password__0'. Invalid character '$avd_hide_password__0'.
W: /base.apk-decompiled/res/values/public.xml:2900: error: resource 'drawable/$avd_hide_password__1' has invalid entry name '$avd_hide_password__1'. Invalid character '$avd_hide_password__1'.
W: /base.apk-decompiled/res/values/public.xml:2901: error: resource 'drawable/$avd_hide_password__2' has invalid entry name '$avd_hide_password__2'. Invalid character '$avd_hide_password__2'.
W: /base.apk-decompiled/res/values/public.xml:2902: error: resource 'drawable/$avd_show_password__0' has invalid entry name '$avd_show_password__0'. Invalid character '$avd_show_password__0'.
W: /base.apk-decompiled/res/values/public.xml:2903: error: resource 'drawable/$avd_show_password__1' has invalid entry name '$avd_show_password__1'. Invalid character '$avd_show_password__1'.
W: /base.apk-decompiled/res/values/public.xml:2904: error: resource 'drawable/$avd_show_password__2' has invalid entry name '$avd_show_password__2'. Invalid character '$avd_show_password__2'.
W: /base.apk-decompiled/res/values/public.xml:2905: error: resource 'drawable/$il_onboarding_agreement__0' has invalid entry name '$il_onboarding_agreement__0'. Invalid character '$il_onboarding_agreement__0'.
W: brut_util_Jar_73193357047232752641802459626510272295.tmp W 10-18 10:24:56 128583 128583 ApkAssets.cpp:137] resources.arsc in APK '/.local/share/apktool/framework/1.apk' is compressed.
W: /base.apk-decompiled/AndroidManifest.xml:42: error: unexpected element found in .

@cswangluo
Copy link

can anyone help?

iBotPeaches added a commit that referenced this issue Nov 27, 2020
iBotPeaches added a commit that referenced this issue Nov 27, 2020
@vramasam
Copy link
Author

vramasam commented Dec 7, 2020

@iBotPeaches

W: decompiled/res/values/public.xml:1447: error: resource 'drawable/$avd_hide_password__0' has invalid entry name '$avd_hide_password__0'. Invalid character '$avd_hide_password__0'.
W: decompiled/res/values/public.xml:1448: error: resource 'drawable/$avd_hide_password__1' has invalid entry name '$avd_hide_password__1'. Invalid character '$avd_hide_password__1'.
W: decompiled/res/values/public.xml:1449: error: resource 'drawable/$avd_hide_password__2' has invalid entry name '$avd_hide_password__2'. Invalid character '$avd_hide_password__2'.
W: decompiled/res/values/public.xml:1450: error: resource 'drawable/$avd_show_password__0' has invalid entry name '$avd_show_password__0'. Invalid character '$avd_show_password__0'.
W: decompiled/res/values/public.xml:1451: error: resource 'drawable/$avd_show_password__1' has invalid entry name '$avd_show_password__1'. Invalid character '$avd_show_password__1'.
W: decompiled/res/values/public.xml:1452: error: resource 'drawable/$avd_show_password__2' has invalid entry name '$avd_show_password__2'. Invalid character '$avd_show_password__2'.
W: decompiled/res/values/public.xml: error: file failed to compile.
brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [localExecutable/mac/aapt2, compile, --dir, decompiled/res, --legacy, -o,
decompiled/build/resources.zip]

I am getting above error .

This is the command I am using
ProcessBuilder processBuilder = new ProcessBuilder(
apktoolPath, "b", "-a", aaptFilePath,
directory, "-o", outputApkPath);

apktoolPath => 2.5.0 (latest one)
aaptFilePath ==> aapt2 (copied in the local path).

Please help us understand is there any problem here. It will be great helpful, if you help in fixing the problem. Please let us know if anyone in this forum able to fix the problem

@iBotPeaches
Copy link
Owner

Please help us understand is there any problem here. It will be great helpful, if you help in fixing the problem. Please let us know if anyone in this forum able to fix the problem

There is no documentation yet for using it as a library. If you can find a failing testcase, feel free to push it up for review. My guess is that using a local provided file does not know aapt2 vs aapt1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants