N/A
1) Decompile an APK with arrays defined in resources
2) Recompile APK without touching the code
-> res/values/arrays.xml does not contain "string-array" elements but "style" elements
Replacing "style" with "string-array" fixes the issue and allows build
We infer this from the contents of the array elements. In my research when I wrote this in 2014, there was no method to determine the type of the elements. So we search for the first element in the array, check what it is and mark the array that type.
Do you have the values of the element of any of the arrays that were matched incorrectly? I can probably update the codebase to check the types of all elements than pick the mode instead of relying on first item.
To add to the OP post. This problem also started occurring in the YouTube apk after 13.42.52 update.
13.42.51 decompiles ok
13.42.52 decompiles arrays.xml wrong
13.43.50 decompiles arrays.xml wrong
13.42.51 Download
13.42.52 Download
There are minor changes in the resources.arsc files. Many of the previously set 0x00 bytes now have something else set to them (0x01, 0x02, ... 0x08, 0x09). Don't really know what they are but I'm hoping you might have an idea (perhaps type flags?) 👍
Thanks for the feedback!
I’ve screened the string-array usage and could not find any type checking or casting in code. The additional bytes being associated with a string-array are not exposed so they get interpreted by the runtime. The implementation resides in Android’s “android.content.res.Resources.getStringArray()” implementation, which I haven’t analyzed.
The “type flags” purpose seems less likely, I’d rather think that the “encoding format” would be part of the persisted string-array. Potentially a reference to this enumeration:
https://docs.oracle.com/javase/7/docs/api/java/nio/charset/StandardCharsets.html
String-arrays used to populate toggles/switches could refer to UTF ASCII, full-text to UTF16 etc.
Could this be the purpose of the additional bytes?
To add to the OP post. This problem also started occurring in the YouTube apk after 13.42.52 update.
13.42.51 decompiles ok
13.42.52 decompiles arrays.xml wrong
13.43.50 decompiles arrays.xml wrong
Same here.
@Razer2015 Were you able to re-build youtube 13.42.51? Building the resources I ran into these 2 errors:
error: No resource identifier found for attribute 'keyboardNavigationCluster' in package 'android'
error: Error: Fraction types not allowed (at 'inset' with value '9.259998%')
Should that be fixed manually or by apktool?
To add to the OP post. This problem also started occurring in the YouTube apk after 13.42.52 update.
13.42.51 decompiles ok
13.42.52 decompiles arrays.xml wrong
13.43.50 decompiles arrays.xml wrongSame here.
@Razer2015 Were you able to re-build youtube 13.42.51? Building the resources I ran into these 2 errors:
error: No resource identifier found for attribute 'keyboardNavigationCluster' in package 'android'
error: Error: Fraction types not allowed (at 'inset' with value '9.259998%')Should that be fixed manually or by apktool?
Yes, with 2.4.0 the arrays.xml problem has been fixed. Just guessing but I guess this commit fixed it: https://github.com/iBotPeaches/Apktool/commit/72368fc0d4fd1653d27be0923b0d11c528b04985
As for your problem, I'm pretty sure it's just some framework issue. Have you used apktool if com.google.android.youtube command before compiling? Decompiling and recompiling without changing anything works fine for me now.
Thanks for your fast reply!
I tried apktool if com.google.android.youtube, but without success. "The system cannot find the file specified". Where am I supposed to find the com.google.android.youtube.apk? I searched on my device as suggested in https://ibotpeaches.github.io/Apktool/documentation/#framework-files, but couldnt find it. Any idea where to get it?
Thanks for your fast reply!
I tried
apktool if com.google.android.youtube, but without success. "The system cannot find the file specified". Where am I supposed to find the com.google.android.youtube.apk? I searched on my device as suggested in https://ibotpeaches.github.io/Apktool/documentation/#framework-files, but couldnt find it. Any idea where to get it?
You already have the APK you are trying to decompile/compile, right? Just replace com.google.android.youtube with the name of that APK. I just used that as an example because that's the default name of the youtube APK.
That was the missing piece, thanks @Razer2015. I stumbled over an issue, might be interesting to any other. When upgrading to a newer apktool version, remove the existing internal framework file 1.apk.
@Razer2015 Are you able to play the recompiled yt app on any device. Are you a reverse engineer, any chance to get in touch with you for a short chat?
@siebeneicher
Yeah, if you re-sign the app, you need to remove signature check and stuff like that. But if your device is rooted, you can just skip the signing (use the original signature) and use it as system app.
But xfileFIN#2811 in Discord if you need to discuss more.
<string-array name="background_audio_policy_entries">
<item>@string/background_audio_policy_on</item>
<item>@string/background_audio_policy_on_if_hh</item>
<item>@string/background_audio_policy_off</item>
</string-array>
<string-array name="background_audio_policy_values">
<item>@string/on</item>
<item>@string/on_if_hh</item>
<item>@string/off</item>
</string-array>
âžś 1926 apktool d com.google.android.youtube_13.42.52-1342523400_minAPI21\(arm64-v8a\)\(nodpi\)_apkmirror.com.apk
I: Using Apktool 2.4.2-f545c2-SNAPSHOT on com.google.android.youtube_13.42.52-1342523400_minAPI21(arm64-v8a)(nodpi)_apkmirror.com.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: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
I: Copying META-INF/services directory
âžś 1926
They are right again. Not sure when fixed. Closing.