Open aboodnour7 opened 7 years ago
Thought I had fixed this in 2.2.2, but doesn't appear to be so. I need to patch the XMLNode class.
I've come across another APK that's suffering from this issue:
Apktool Version: 2.2.2 Operating System: Both Linux and Mac APK From: https://forum.xda-developers.com/android/apps-games/ps4-remote-play-android-thread-t3068225
$ apktool d RemotePlayPortV5.1_ITB.apk
...
$ apktool b RemotePlayPortV5.1_ITB
I: Using Apktool 2.2.2 on RemotePlayPortV5.1_ITB.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: /root/.local/share/apktool/framework/1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Baksmaling classes.dex...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
root@99033f046f3d:/usr/src/apk# apktool b RemotePlayPortV5.1_ITB
I: Using Apktool 2.2.2
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether resources has changed...
I: Building resources...
W: /usr/src/apk/RemotePlayPortV5.1_ITB/res/layout/companionutil_layout_alert_dialog.xml:2: error: Error parsing XML: not well-formed (invalid token)
W:
W: /usr/src/apk/RemotePlayPortV5.1_ITB/res/layout/companionutil_layout_alert_dialog_game2_confirm.xml:2: error: Error parsing XML: not well-formed (invalid token)
W:
W: /usr/src/apk/RemotePlayPortV5.1_ITB/res/layout/companionutil_layout_alert_dialog_game_confirm.xml:2: error: Error parsing XML: not well-formed (invalid token)
W:
Exception in thread "main" brut.androlib.AndrolibException: brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/tmp/brut_util_Jar_4284272564605293496.tmp, p, --forced-package-id, 127, --min-sdk-version, 17, --target-sdk-version, 19, --version-code, 10500, --version-name, 1.5.0, --no-version-vectors, -F, /tmp/APKTOOL6062192940819296925.tmp, -0, arsc, -0, arsc, -I, /root/.local/share/apktool/framework/1.apk, -S, /usr/src/apk/RemotePlayPortV5.1_ITB/res, -M, /usr/src/apk/RemotePlayPortV5.1_ITB/AndroidManifest.xml]
at brut.androlib.Androlib.buildResourcesFull(Androlib.java:477)
at brut.androlib.Androlib.buildResources(Androlib.java:411)
at brut.androlib.Androlib.build(Androlib.java:310)
at brut.androlib.Androlib.build(Androlib.java:263)
at brut.apktool.Main.cmdBuild(Main.java:227)
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_4284272564605293496.tmp, p, --forced-package-id, 127, --min-sdk-version, 17, --target-sdk-version, 19, --version-code, 10500, --version-name, 1.5.0, --no-version-vectors, -F, /tmp/APKTOOL6062192940819296925.tmp, -0, arsc, -0, arsc, -I, /root/.local/share/apktool/framework/1.apk, -S, /usr/src/apk/RemotePlayPortV5.1_ITB/res, -M, /usr/src/apk/RemotePlayPortV5.1_ITB/AndroidManifest.xml]
at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:440)
at brut.androlib.Androlib.buildResourcesFull(Androlib.java:463)
... 5 more
Caused by: brut.common.BrutException: could not exec (exit code = 1): [/tmp/brut_util_Jar_4284272564605293496.tmp, p, --forced-package-id, 127, --min-sdk-version, 17, --target-sdk-version, 19, --version-code, 10500, --version-name, 1.5.0, --no-version-vectors, -F, /tmp/APKTOOL6062192940819296925.tmp, -0, arsc, -0, arsc, -I, /root/.local/share/apktool/framework/1.apk, -S, /usr/src/apk/RemotePlayPortV5.1_ITB/res, -M, /usr/src/apk/RemotePlayPortV5.1_ITB/AndroidManifest.xml]
at brut.util.OS.exec(OS.java:95)
at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:434)
... 6 more
Example invalid .xml:
<?xml version="1.0" encoding="utf-8"?>
<o.ﺗ android:layout_gravity="center" android:orientation="vertical" android:background="@drawable/companionutil_drawable_alert_dialog" android:layout_width="fill_parent" android:layout_height="wrap_content" landscape_marginLeft="33dp" landscape_marginRight="33dp" portrait_marginLeft="11dp" portrait_marginRight="11dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<com.playstation.companionutil.CompanionUtilAdjustTextView android:textSize="16.0dip" android:textColor="#ffffffff" android:id="@id/com_playstation_companionutil_id_alert_text" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="11.0dip" android:layout_marginTop="17.0dip" android:layout_marginRight="11.0dip" android:text="" android:lineSpacingExtra="1.0dip" />
<com.playstation.companionutil.CompanionUtilAdjustButton android:textSize="16.0dip" android:textColor="#ffffffff" android:id="@id/com_playstation_companionutil_id_alert_positive_button" android:background="@drawable/companionutil_drawable_alert_dialog_button" android:layout_width="fill_parent" android:layout_height="28.0dip" android:layout_marginLeft="11.0dip" android:layout_marginTop="15.0dip" android:layout_marginRight="11.0dip" android:layout_marginBottom="15.0dip" android:text="@string/com_playstation_companionutil_msg_ok" />
</o.ﺗ>
PS4 Remote Play Port (https://forum.xda-developers.com/android/apps-games/ps4-remote-play-android-thread-t3068225)
Have you tried apktool d, apktool b without changing anything? Yes If you are trying to install a modified apk, did you resign it? No Are you using the latest apktool version? Yes
Is it possible to manually work around this issue for now?
Bump! Any update on this issue? I'm dealing with special characters in classes, method names, and XML tag names!
@aletorrado There is no update to report. Updates to bug reports will always be made in the respective bug report, so you don't need to worry. Any related update will be posted in here.
I have struck this issue with v7.0.1 of the Netflix apk
I have also struck this issue with an app i'm currently trying to recompile
FWIW, this seems to come down to a bug in libexpat which doesn't allow the proper character set for names. When a XML resources refers to proguarded names, it has good chances to crash. See https://github.com/libexpat/libexpat/issues/171
2020 update. Still an issue.
➜ 1407 apktool b 1407 --use-aapt2
I: Using Apktool 2.4.2-f545c2-SNAPSHOT
I: Checking whether sources has changed...
I: Checking whether sources has changed...
I: Checking whether sources has changed...
I: Checking whether resources has changed...
I: Building resources...
W: /home/ibotpeaches/Downloads/Apktool/1407/1407/res/animator/2130837504.xml:4: error: not well-formed (invalid token).
W: /home/ibotpeaches/Downloads/Apktool/1407/1407/res/animator/2130837504.xml: error: file failed to compile.
W: /home/ibotpeaches/Downloads/Apktool/1407/1407/res/animator/2130837509.xml:4: error: not well-formed (invalid token).
W: /home/ibotpeaches/Downloads/Apktool/1407/1407/res/animator/2130837509.xml: error: file failed to compile.
W: /home/ibotpeaches/Downloads/Apktool/1407/1407/res/color/2131099651.xml:4: error: not well-formed (invalid token).
W: /home/ibotpeaches/Downloads/Apktool/1407/1407/res/color/2131099651.xml: error: file failed to compile.
W: /home/ibotpeaches/Downloads/Apktool/1407/1407/res/color/2131099666.xml:4: error: not well-formed (invalid token).
W: /home/ibotpeaches/Downloads/Apktool/1407/1407/res/color/2131099666.xml: error: file failed to compile.
W: /home/ibotpeaches/Downloads/Apktool/1407/1407/res/color/2131099667.xml:4: error: not well-formed (invalid token).
W: /home/ibotpeaches/Downloads/Apktool/1407/1407/res/color/2131099667.xml: error: file failed to compile.
W: /home/ibotpeaches/Downloads/Apktool/1407/1407/res/color/2131099668.xml:4: error: not well-formed (invalid token).
W: /home/ibotpeaches/Downloads/Apktool/1407/1407/res/color/2131099668.xml: error: file failed to compile.
W: /home/ibotpeaches/Downloads/Apktool/1407/1407/res/color/2131099669.xml:4: error: not well-formed (invalid token).
W: /home/ibotpeaches/Downloads/Apktool/1407/1407/res/color/2131099669.xml: error: file failed to compile.
W: /home/ibotpeaches/Downloads/Apktool/1407/1407/res/color/2131099670.xml:4: error: not well-formed (invalid token).
W: /home/ibotpeaches/Downloads/Apktool/1407/1407/res/color/2131099670.xml: error: file failed to compile.
W: /home/ibotpeaches/Downloads/Apktool/1407/1407/res/color/2131099671.xml:4: error: not well-formed (invalid token).
W: /home/ibotpeaches/Downloads/Apktool/1407/1407/res/color/2131099671.xml: error: file failed to compile.
W: /home/ibotpeaches/Downloads/Apktool/1407/1407/res/color/2131099896.xml:5: error: not well-formed (invalid token).
W: /home/ibotpeaches/Downloads/Apktool/1407/1407/res/color/2131099896.xml: error: file failed to compile.
brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/tmp/brut_util_Jar_8728117719843997481760221012075490107.tmp, compile, --dir, /home/ibotpeaches/Downloads/Apktool/1407/1407/res, --legacy, -o, /home/ibotpeaches/Downloads/Apktool/1407/1407/build/resources.zip]
➜ 1407
Is the problem not resolved yet? I am having the same problem now.
Is the problem not resolved yet? I am having the same problem now.
Ticket looks open and unresolved to me. So no isn't resolved.
Happens for me with resource xml with $
in tag name, e.g.
<?xml version="1.0" encoding="utf-8"?>
<o.RatingCompat$1 id="@id/expanded_menu" layout_width="?panelMenuListWidth" layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android" />
Can anyone please provide a sample apk with source code or the proguard configuration file to reproduce this issue?
Source code is not available for apps provided in above comments and issue
@sriteja777 did you managed to fix it somehow?
@sriteja777 here is an example of failing APK: https://file.io/xjeXQrwAXR6s
@iBotPeaches does this have to do with a bug in libexpat as mentioned above? And if so, would you consider bundling a patched version of libexpat with your packages?
@iBotPeaches does this have to do with a bug in libexpat as mentioned above? And if so, would you consider bundling a patched version of libexpat with your packages?
I have not done enough research to know if that is true. So unsure.
@iBotPeaches would mind pointing me to the code that throws error: Error parsing XML: not well-formed (invalid token)
?
I want to see if I can figure out what's going on here, but my Java-fu is minimal. If it is indeed libexpat issue, it should be possible to patch it and include with your files, as it has no other dependencies.
@iBotPeaches would mind pointing me to the code that throws
error: Error parsing XML: not well-formed (invalid token)
?I want to see if I can figure out what's going on here, but my Java-fu is minimal. If it is indeed libexpat issue, it should be possible to patch it and include with your files, as it has no other dependencies.
That is in aapt/aapt2 so you won't find it. You'll want to check
@aravi365 No I wasn't able to fix it.
@dimitry-ishenko Thanks for sharing that, but I already have some apks with this error. What I am looking is the source code of app that can reproduce this issue.
@sriteja777 oic. Sorry misunderstood. But IMHO you can create one yourself and just add an invalid character (eg, $
) to an XML tag.
From what I understood it's aapt2
which causes the failure. And it in turn uses libexpat
which doesn't support XML 1.0 r5 where they've allowed additional chars in XML tags.
Any news on this?
hi guys is anybody slove this problem ??
@iBotPeaches couldn't you - optionally - pass some params to the XML tool so that it ignores these errors? The XML format errors come from the source APK so they're probably OK with those errors.
Anyone figured out a solution here? Bumping against the same problem myself.
Here is another XML that apktool
struggles with. I presume it's due to R8 or DexGuard obfuscating the class names.
<?xml version="1.0" encoding="utf-8"?>
<ql.ࡩ᫋ᫎ android:id="@id/alertView" android:focusable="true" android:clickable="true" android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
<ImageView android:id="@id/alert_imageView_background" android:layout_width="0.0dip" android:layout_height="0.0dip" android:src="@null" android:scaleType="centerCrop" android:importantForAccessibility="no" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" />
<LinearLayout android:gravity="center" android:orientation="vertical" android:id="@id/alert_container" android:background="@drawable/rebrand_alert_view_background" android:paddingTop="@dimen/grid_8x" android:paddingBottom="@dimen/grid_8x" android:layout_width="0.0dip" android:layout_height="wrap_content" android:minHeight="@dimen/grid_52x" android:paddingStart="@dimen/grid_4x" android:paddingEnd="@dimen/grid_4x" android:layout_marginHorizontal="@dimen/grid_12x" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent">
<ImageView android:id="@id/alert_imageView_icon" android:layout_width="@dimen/grid_6x" android:layout_height="@dimen/grid_6x" android:importantForAccessibility="no" app:tint="@color/rebrand_icon_color" />
<TextView android:id="@id/alert_textView_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="@dimen/grid_2x" style="@style/Standard.Bold.Primary.Text" />
<TextView android:gravity="center" android:id="@id/alert_textView_description" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/grid_4x" android:minLines="2" style="@style/Small.Regular.Primary.Text" />
</LinearLayout>
@iBotPeaches Here's the full app that's giving me headache. Figured it might be of interest to take a look at.
If you try to run apktool d base.apk && apktool b base.apk
you'll run into lots of not well-formed (invalid token).
errors.
Having the same problem, haven't found a fix yet. 😞
Same issue here.
I: Building resources...
W: /home/dpi/decompile/xxxxxxxx/res/layout-land/APKTOOL_DUMMYVAL_0x7f0e004c.xml:7: error: not well-formed (invalid token).
Problematic XML line
<com.xxxxx.productinfra.avatar.squid.AvatarSquidUpsellView android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginBottom="8.0dip" android:layout_marginStart="16.0dip" android:layout_marginEnd="16.0dip" app:="2" />
app:="2"
triggers the error
Any fix?! I have the same issue, but i think the problem is that the application's APK is splited , any idea how to combine them?
@orelamihay86 - You can use ApkEditor to merge https://github.com/REAndroid/APKEditor?tab=readme-ov-file#3--merge
However, why do you think this has anything to do with an invalid-token error? You don't have to respond to unrelated issues with this.
hy do you think this has anything to do with an invalid-token error? You don't have to respond to u
Because this is the link that you sent me regarding my issue..
And I suspect that this issue because in the build process it searched for XMLs that exists in the splited APK, but i am not sure, I am new in this world.
Information
Steps to Reproduce
apktool d music.apk -o output
(You will notice non-ascii characters in decompiled files both Smali and XML files which probably the reason recompiling fails)apktool b output
, it would fail leaving the following errorsAPK
Musixmatch Lyrics (https://play.google.com/store/apps/details?id=com.musixmatch.android.lyrify&hl=en)
Questions to ask before submission
apktool d
,apktool b
without changing anything? - Yes