We can get Build infomation such as VERSION.SKD_INT by android.os.Build. But all of them are static final
like Build.VERSION#SDK_INT. If I understand correctly, that means these value will be decided in the complie time. My question is how do they change on different devices even if it's the same apk?
Take SDK_INT for example, we can check version code constants work with older versions. That means android.os.Build.VERSION_CODES.TIRAMISU
is decided in the compile time. How wasn't android.os.Build.VERSION.SDK_INT
decided in complie time?
if (android.os.Build.VERSION.SDK_INT >=
android.os.Build.VERSION_CODES.TIRAMISU) ...
If you take a look at the android.os.Build
class, you will see that it comes from the android.jar
library.
This library, as you're seeing it from Android Studio, only contains stubs and won't be embedded within your app.
At runtime, your application will use the android.jar
that is present on your device and the android.os.Build.VERSION.SDK_INT
property will effectively be set to represent your current OS version.