Is Android SDK compiled/linked to APK or installed on Android device?
Asked Answered
I

2

6

First some premises:

  1. Android applications make use of Android SDK API classes.

  2. A class definition is some code or parts of code, which gets compiled into machine code/bytecode.

  3. I assume that all (or most of) the classes/packages that make up Android SDK API are listed under:
    https://developer.android.com/reference/packages.html https://developer.android.com/reference/classes.html

    Which is a lot!


Now the question:

Where do these codes/data reside? Are they compiled along with the application code into the APK file or do they exist inside the Android OS on a device, in which case the application should dynamic-link to them?

If they're present on the device, then what difference does it make to compile the application with newer Android SDK versions (per compileSdkVersion in Android Studio for example)?

Let's say the "Android SDK Build-Tools" (which is not the same as "SDK Platform" (according to "SDK Manager" window!) and has its own versioning) takes care of compiling your code and therefore newer version mean better bytecode optimization and faster JAVA -> DEX translation!? build/compile tools

Does "SDK Platform" which you compile your android application against and set it's version with compileSdkVersion keyword, contain solely class declarations and reference-symbols?! Android SDK

What about Google APIs (e.g. Google Maps API)?

What about Android Support Library?

Inclinable answered 3/10, 2016 at 19:28 Comment(0)
A
3

The Android SDK code is baked into the device, and is not part of your apk.

Stuff you need to include via gradle compile gets into your apk (e.g. Support Library)

Apotheosize answered 6/10, 2016 at 13:46 Comment(0)
M
0

The Android core SDK classes are provided by the Android runtime instance that runs per App, you might call it the Android virtual machine if you will. When your App needs to load a specific Android framework class, a Classloader will load it for you in a process similar to dynamic-link as you mentioned.

There is not much you can do to change the version of the framework running on the device. However, the reason you need to specify the different minimumSdk and targetSdk, is for the lint/compiler tools to indicate you what functions/apis might not be present at runtime in specific framework versions. Based on this information you provide wrappers/adapters or simply if/else logic to provide an alternative functionality or simply to avoid a ClassNotDefinedException or MethodNotFoundException at runtime. It is basically a dev tool to help you visualize what could be wrong with other versions different from the one you are compiling against.

Certainly when you compile it, it produces references-symbols in a similar way as if reference an included library. The VM Classloader will resolve the actual file to load at runtime. Not quite sure how Google Apis work but it might be provided as well, in the case of the support library it gets included as far as I know.

Merv answered 7/12, 2022 at 16:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.