smali: restore -api option and limit to 29#3879
Conversation
|
Accidental changes for the |
|
with that max 29 sdkver for dex, -api is not needed at all but still thanks for that :) |
Nah it's unchanged, just moved it out of |
Exactly. Realistically with the max 29 limit, |
if you removed -api option then you should limit it to 29 already, still its all good now. i already had smali working fine so only apktool was affected for me. |
|
Do you think we should emit a log message if api > 29 and say something like "Dropping API level to 29 from x, due to smali issue y"? I just want to avoid some "magic" transformation that may go unnoticed in a year or two |
best way would be to detect dex version from available classes.dex file in apk and that too while decompiling. there might be other ways too but this seems better |
No? What dex version is used for smali is not something the user should be concerned about, nor the user needs to understand the relationship between That's why I think You can't predict what will happen in a year or two, but smali is currently broken, the VersionMap doesn't match reality (no app is built with 040 or 041 regardless of API, they shouldn't have touched it).
smali/baksmali doesn't support specifying the dex version, only an API version for opcodes, and we already get the resolved API version from dex if needed (JARs). Current method is fine. You won't see APKs with dex versions not matching the app's minSdkVersion, that's hardcoded in build tools. |
#3699 wasn't enough because it only applied to JARs. If you decompiled an app with minSdkVersion > 29, then you wouldn't get the expected dex 039 files. This wasn't due to the PR that Connor mentioned in #3775, it was actually this change, specifically in This PR fixes #3775. Now even if the app has |
Restored the
-apioption forbuildmode for now, and limited opcode API level forSmaliBuilderto <= 29.Realistically, the
-apioption is obsolete for bothdecodeandbuildmodes, because the process is already automatic and shouldn't be messed with.All we had to do is limit the opcode API level for
SmaliBuilderto make sure we assemble dex 039 or older.dex 040 and 041 don't exist in the wild, and smali assembling for dex 041 is broken for a long time now (writes incomplete header).