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

[BUG] android:localeConfig in Manifest #2756

Open
wortel-za opened this issue Feb 9, 2022 · 25 comments
Open

[BUG] android:localeConfig in Manifest #2756

wortel-za opened this issue Feb 9, 2022 · 25 comments
Labels

Comments

@wortel-za
Copy link

Information

  1. Apktool Version (apktool -version) -2.6.1 and older
  2. Operating System (Mac, Linux, Windows) - Mac
  3. APK From? (Playstore, ROM, Other) - Playstore

Stacktrace/Logcat

Include stacktrace here
W: /xxx/BookmarkFolder_v5.0.5_129/res/xml/locales_config.xml:3: error: unbound prefix.
W: /xxx/BookmarkFolder_v5.0.5_129/res/xml/locales_config.xml: error: file failed to compile.
brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/var/folders/sm/q39kpprx0175hypt_zz76qb00000gn/T/brut_util_Jar_70428711240655456118660710679018899199.tmp, compile, --dir, /xxx/BookmarkFolder_v5.0.5_129/res, --legacy, -o, /xxx/BookmarkFolder_v5.0.5_129/build/resources.zip]

### Steps to Reproduce
1. `apktool  -advance   b   -d  -p /Applications/Tools/TelefonApps/MyApkTool.app/Contents/Resources/framework/ --use-aapt2 '/xxx/BookmarkFolder_v5.0.5_129/'

### Frameworks
If this APK is from an OEM ROM (Samsung, HTC, LG). Please attach framework files
(`.apks` that live in `/system/framework` or `/system/priv-app`)

### APK
If this APK can be freely shared, please upload/attach a link to it.
BookmarkFolder_v5.0.5_129.apk

### 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? not possible
3. Are you using the latest apktool version? yes tried also older versions

Error file : /xxx/BookmarkFolder_v5.0.5_129/res/xml/locales_config.xml
W: /xxx/BookmarkFolder_v5.0.5_129/res/xml/locales_config.xml:3: error: unbound prefix.
<?xml version="1.0" encoding="utf-8"?>
<locale-config>
    <locale android:name="ca" />
    <locale android:name="da" />
    <locale android:name="fa" />
   ....
</locale-config>

@wortel-za wortel-za changed the title [BUG] [BUG] android:localeConfig in Manifest Feb 12, 2022
@iBotPeaches
Copy link
Owner

Since no apk. Is the extent of this test I add a new locales_config.xml file to res/xml with

<?xml version="1.0" encoding="utf-8"?>
<locale-config>
    <locale android:name="ca" />
    <locale android:name="da" />
    <locale android:name="fa" />
   ....
</locale-config>

?

@KevinX8
Copy link

KevinX8 commented Feb 15, 2022

I just hit this issue with YouTube 17.05.38 https://www.apkmirror.com/apk/google-inc/youtube/youtube-17-05-38-release/youtube-17-05-38-android-apk-download/, all you have to do is decompile and recompile and it will refuse to build because of that file

@wortel-za
Copy link
Author

in Manifest:

android:localeConfig="@xml/locales_config"

res/values/public.xml

res/xml/locales_config.xml

....

the locales_config.xml file is used exclusively in the base.apk of bundles (apkmirror .apkm),
the apk as a single apk does not contain this file.
the specification android:localeConfig="@xml/locales_config" in the manifest
is also only in the base.apk of a bundle.

Example: Web Video Cast
Apk as Bundle:

https://www.apkmirror.com/apk/instantbits-inc/web-video-cast-browser-to-tv-chromecastdlna/web-video-cast-browser-to-tv-chromecastdlna-5-5-5b2-release/web-video-cast-browser-to-tv-5-5-5b2-android-apk-download/

Apk as Single File:

https://www.apkmirror.com/apk/instantbits-inc/web-video-cast-browser-to-tv-chromecastdlna/web-video-cast-browser-to-tv-chromecastdlna-5-5-5b2-release/web-video-cast-browser-to-tv-5-5-5b2-2-android-apk-download/

@empctn
Copy link

empctn commented Feb 23, 2022

apktool

The same problem is happening to me in some apks

@tannercollin
Copy link

I think I fixed this by adding ? to the XML tags like so:

<?locale android:name="ca" /?>
<?locale android:name="da" /?>
<?locale android:name="fa" /?>
... etc

But now I get an output/AndroidManifest.xml:8: error: attribute android:localeConfig not found error.

@iBotPeaches
Copy link
Owner

Sorry folks, still not replicating this.

➜  2756 apktool d 2756.apk 
I: Using Apktool 2.6.1 on 2756.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: /home/ibotpeaches/.local/share/apktool/framework/1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Baksmaling classes.dex...
I: Baksmaling classes2.dex...
I: Baksmaling classes3.dex...
I: Baksmaling classes4.dex...
I: Baksmaling classes5.dex...
I: Baksmaling assets/audience_network.dex...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
I: Copying META-INF/services directory
➜  2756 apktool b 2756 --use-aapt2
I: Using Apktool 2.6.1
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes3 folder into classes3.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes2 folder into classes2.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes5 folder into classes5.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes4 folder into classes4.dex...
I: Checking whether sources has changed...
I: Smaling smali_assets folder into assets.dex...
I: Checking whether resources has changed...
I: Building resources...
I: Copying libs... (/lib)
I: Copying libs... (/kotlin)
I: Copying libs... (/META-INF/services)
I: Building apk file...
I: Copying unknown files/dir...
I: Built apk...
➜  2756 

I used this one - https://www.apkmirror.com/apk/instantbits-inc/web-video-cast-browser-to-tv-chromecastdlna/web-video-cast-browser-to-tv-chromecastdlna-5-5-5b2-release/web-video-cast-browser-to-tv-5-5-5b2-2-android-apk-download/

@wortel-za
Copy link
Author

@iBotPeaches
take the base.apk out of the bundle:
https://www.apkmirror.com/apk/instantbits-inc/web-video-cast-browser-to-tv-chromecastdlna/web-video-cast-browser-to-tv-chromecastdlna-5-5-5b2-release/web-video-cast-browser-to-tv-5-5-5b2-android-apk-download/

the locales_config.xml file is used exclusively in the base.apk of bundles (apkmirror .apkm),
the apk as a single apk does not contain this file.
the specification android:localeConfig="@xml/locales_config" in the manifest
is also only in the base.apk of a bundle.

@iBotPeaches
Copy link
Owner

Okay thanks, now I replicate.

I: Building resources...
W: /home/ibotpeaches/Downloads/Apktool/2756/base/res/xml/locales_config.xml:3: error: Error parsing XML: unbound prefix
W: 
brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/tmp/brut_util_Jar_27112266611582560847934334344813836868.tmp, p, --forced-package-id, 127, --min-sdk-version, 21, --target-sdk-version, 30, --version-code, 4146, --version-name, 5.5.5b2, --no-version-vectors, -F, /tmp/APKTOOL2635192290980837099.tmp, -e, /tmp/APKTOOL4614977205943472114.tmp, -0, arsc, -I, /home/ibotpeaches/.local/share/apktool/framework/1.apk, -S, /home/ibotpeaches/Downloads/Apktool/2756/base/res, -M, /home/ibotpeaches/Downloads/Apktool/2756/base/AndroidManifest.xml]
➜  2756 aapt d xmltree base.apk res/xml/locales_config.xml
E: locale-config (line=0)
  E: locale (line=0)

Assigning bug.

@Gourov
Copy link

Gourov commented Mar 4, 2022

I have encounter a same problem with this app ....
https://play.google.com/store/apps/details?id=org.hostedgames.zexsh

Its a split and problem with base.apk ...


I: Using Apktool 2.6.1
I: Smaling smali folder into classes.dex...
I: Building resources...
W: D:\InstallationFiles\ApkEasyTool_v1.59.2\1-Decompiled APKs\base\res\xml\locales_config.xml:3: error: Error parsing XML: unbound prefix
W: 
brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\Gourov\AppData\Local\Temp\brut_util_Jar_159871407586383149737413562893265274635.tmp, p, --forced-package-id, 127, --min-sdk-version, 19, --target-sdk-version, 30, --version-code, 26, --version-name, 3.0.2, --no-version-vectors, -F, C:\Users\Gourov\AppData\Local\Temp\APKTOOL8716755988559573126.tmp, -e, C:\Users\Gourov\AppData\Local\Temp\APKTOOL1637710390933913995.tmp, -0, arsc, -I, C:\Users\Gourov\AppData\Local\apktool\framework\1.apk, -S, D:\InstallationFiles\ApkEasyTool_v1.59.2\1-Decompiled APKs\base\res, -M, D:\InstallationFiles\ApkEasyTool_v1.59.2\1-Decompiled APKs\base\AndroidManifest.xml]

For now , It can be fixed by following the steps below....
delete file \res\xml\locales_config.xml
open file \res\values\public.xml and delete line <public type="xml" name="locales_config" id="0x7f110003" />
open file AndroidManifest.xml and delete declaration android:localeConfig="@xml/locales_config"

Will be really happy if this issue solves in next update 😃

@KrishnaST
Copy link

I have encounter a same problem with this app .... https://play.google.com/store/apps/details?id=org.hostedgames.zexsh

Its a split and problem with base.apk ...


I: Using Apktool 2.6.1
I: Smaling smali folder into classes.dex...
I: Building resources...
W: D:\InstallationFiles\ApkEasyTool_v1.59.2\1-Decompiled APKs\base\res\xml\locales_config.xml:3: error: Error parsing XML: unbound prefix
W: 
brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\Gourov\AppData\Local\Temp\brut_util_Jar_159871407586383149737413562893265274635.tmp, p, --forced-package-id, 127, --min-sdk-version, 19, --target-sdk-version, 30, --version-code, 26, --version-name, 3.0.2, --no-version-vectors, -F, C:\Users\Gourov\AppData\Local\Temp\APKTOOL8716755988559573126.tmp, -e, C:\Users\Gourov\AppData\Local\Temp\APKTOOL1637710390933913995.tmp, -0, arsc, -I, C:\Users\Gourov\AppData\Local\apktool\framework\1.apk, -S, D:\InstallationFiles\ApkEasyTool_v1.59.2\1-Decompiled APKs\base\res, -M, D:\InstallationFiles\ApkEasyTool_v1.59.2\1-Decompiled APKs\base\AndroidManifest.xml]

For now , It can be fixed by following the steps below.... delete file \res\xml\locales_config.xml open file \res\values\public.xml and delete line <public type="xml" name="locales_config" id="0x7f110003" /> open file AndroidManifest.xml and delete declaration android:localeConfig="@xml/locales_config"

Will be really happy if this issue solves in next update 😃

This is working.

@wortel-za
Copy link
Author

update internal framework to API 33 (Tiramisu Privacy Preview) has solved this problem. No further action needed

@iBotPeaches
Copy link
Owner

Okay thanks @wortel-za - might see if I can add a test case for this. Otherwise closing.

@Gourov
Copy link

Gourov commented Jul 18, 2022

@wortel-za can you please write some details about updating internal framework ?

@wortel-za
Copy link
Author

wortel-za commented Jul 19, 2022

@Gourov
install lastest version and delete your old 1.apk framework before using

@GHRoss
Copy link

GHRoss commented Aug 16, 2022

@wortel-za Could you provide more thorough instructions, please? I'm trying to use this with Objection but hitting this issue.

@AntonSamokat
Copy link

AntonSamokat commented Sep 9, 2022

I encountered the same problem with telegram-sms apk.
Using last version of Apktool v2.6.1 and JDK 1.8.0_202.

update internal framework to API 33 (Tiramisu Privacy Preview) has solved this problem. No further action needed

@wortel-za It is not clear how this can help.

@wortel-za
Copy link
Author

wortel-za commented Sep 9, 2022

@sunkrop
the lastest build is
apktool-2.6.2-63a8d09-SNAPSHOT-small.jar NOT 2.6.1
How to Build

@AidenLai
Copy link

AidenLai commented Dec 3, 2022

Still have same problem on 2.7.0
when I re-compile following app

@Francesco146
Copy link

Francesco146 commented Jan 18, 2023

Can confirm that this is still an open issue on v2.7.0

@mhmdshz
Copy link

mhmdshz commented Apr 15, 2023

For now , It can be fixed by following the steps

1-delete all locale from locales_config.xml file
test

2-build it as normal

@iBotPeaches iBotPeaches modified the milestones: v2.8.1, v2.8.2 Jul 20, 2023
@iBotPeaches
Copy link
Owner

iBotPeaches commented Aug 13, 2023

Sorry for delay on this. I took a look.

The original error is this:

W: /media/ibotpeaches/AOSP/Apktool/2756/base/res/xml/locales_config.xml:3: error: unbound prefix.
W: /media/ibotpeaches/AOSP/Apktool/2756/base/res/xml/locales_config.xml: error: file failed to compile.

Which is basically because there are no namespaces, so it can't properly resolve these properties. Oddly though this namespace isn't found so Apktool isn't doing anything wrong.

➜  2756 aapt2 d xmltree base.apk --file res/xml/locales_config.xml
E: locale-config (line=0)
    E: locale (line=0)
      A: android:name="ja" (Raw: "ja")
    E: locale (line=0)

So if we add the namespace

<?xml version="1.0" encoding="utf-8"?>
<locale-config xmlns:android="http://schemas.android.com/apk/res/android">
    <locale android:name="ja" />
    <locale android:name="bg" />
    <locale android:name="nl" />
    <locale android:name="es" />

The build works.

➜  2756 apktool b base --use-aapt2                                              
I: Using Apktool v2.8.1-41-0e226928-SNAPSHOT
I: Checking whether resources has changed...
I: Building resources...
I: Copying libs... (/kotlin)
I: Copying libs... (/META-INF/services)
I: Building apk file...
I: Copying unknown files/dir...
I: Built apk into: base/dist/base.apk
➜  2756

So I think I'll patch Apktool to explicitly look for the locale-config XML tag and add the namespace during disassembly. My guess is this is a bug in Android in generating this file, as if you manually create it per: https://developer.android.com/guide/topics/resources/app-languages you add the namespace.

@iBotPeaches
Copy link
Owner

This is more difficult than I thought for Apktool to handle at the moment. During disassembly we use a pull-parser so we can only extract values and mutate them during extraction.

So to do a pure insertion of a missing key - we either have to treat it like we do for the AndroidManifest and trigger a full copy/modify, but that seems hacky. I need to figure out a good method for the ResFileDecoder to detect specify files that have modifications required post disassembly.

@iBotPeaches
Copy link
Owner

I've got no easy way to automate this at the time, so dropping into backlog. Please add the namespace manually if you encounter this issue.

@Francesco146
Copy link

these workaround stopped working in the latest version (Apktool 2.9.3). deleting locales_config declaration or adding the namespace only leads to a different kind of error during compilation:

I: Building resources...
W: youtube/AndroidManifest.xml:107: error: attribute android:localeConfig not found.
W: error: failed processing manifest.

or this error:

I: Building resources...
W: youtube/res/xml/locales_config.xml:3: error: unbound prefix.
W: youtube/res/xml/locales_config.xml: error: file failed to compile.

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

No branches or pull requests