-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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] Samsung Android 15 malformed compiled jar #3775
Comments
Samsung Android 15 frameworks are packed using DEX format 039, use the "-api 29" flag to properly decompile/recompile back the jar files. |
Additionally, looking at the logs you provided you used the "Batch ApkTool" script rather than this tool itself, that script is not in any way connected to the OG apktool/smali tools, so if you have an issue specific with it you should be reporting it to the script author, not here. |
Thank you for your reply Salvo. Wouldn't have any impact on Android 15 resources.arc using "-api 29" instead "-api 35" ? |
Standalone apktool will handle jar files just fine as it detects the correct API version to use by checking the DEX file version format if not specified: Apktool/brut.apktool/apktool-lib/src/main/java/brut/androlib/ApkDecoder.java Lines 309 to 312 in e547948
So I'm pretty sure the script you're using is messing up with the API value as API 35 forces baksmali/smali to repack DEX files using 041 format which isn't fully supported yet by the tool, also, it won't match the original version from the untouched jar (039 vs 041). Imho, the best thing to do at the moment is to handle de-recompiling of apks/dexs files separately in a way where it matches the original as much as possible to avoid issues, what I personally do is to use the |
Okay, so I'm trying to catch up on this and refresh myself.
So in my summary. In the meantime while API 35 is not well supported by downstream smali - manually invoke Apktool during disassembly with an api (29)? to trick the intended dex version in this specific usecase. |
As explained in my previous comment, the api flag is not required when handling jar files as baksmali will automatically detect the correct minSdkVersion to use depending the DEX format version (#3699), so imho the issue is caused by that third party script which is instead setting the api flag to 35 and forcing baksmali/smali to use DEX 041 format as opposite of the original jar DEX 039 format. The same cannot be said for apk files: I'm guessing apktool fetches the minSdkVersion via the app manifest, but there are some instances where this doesn't matches the actual DEX format version used in the apk (eg. Samsung system apps use minSdkVersion 34 but still use DEX 039 instead of 040), for this reason I suggested to handle the resources/smali decompiling manually in this specific instance. |
I made a some tests forcing api29 in the tool. I used official apktool 2.9.3 and 2.11 and smali/baksmali 3.0.3 and 3.0.9.
Batch ApkTool : 3.8.0
|
You can't decompile/recompile the Settings app by setting the API flag to 29 because, obviously, it's an API 35 app. Use the latest available apktool version (upstream is better), then separately decompile/recompile the apk/dex files with the proper API version for each. Until a way to match the DEX version format of the original apk gets integrated in the tool (assuming any of the maintainers is interested in this, I have no idea whether or not this minSdkVersion mismatch is something Samsung specific), this is the way to go. |
Salvo, have you managed to boot a android 15 device with a modified system app (Settings or SystemUI) with this procedure? I tried last evening to use a SecSettings (S24U S928B device) modified using your above method but the device didn't boot. |
Information
apktool -version
) - apktool_2.11.1_20250117.jarjava --version
) - 20.0.2Stacktrace/Logcat
https://drive.google.com/drive/folders/1HbnHabVtNxdxn0LxLwpA0dJxhVKv6Or0?usp=sharing
Steps to Reproduce
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
)https://drive.google.com/drive/folders/1HbnHabVtNxdxn0LxLwpA0dJxhVKv6Or0?usp=sharing
APK
If this APK can be freely shared, please upload/attach a link to it.
https://drive.google.com/drive/folders/1HbnHabVtNxdxn0LxLwpA0dJxhVKv6Or0?usp=sharing
Questions to ask before submission
apktool d
,apktool b
without changing anything? YesThe text was updated successfully, but these errors were encountered: