Android Builders Weblog: Extending the Android SDK
Posted by Anton Hansson, Software program EngineerAndroid 10 and better help Modular System Components that permit us to expedite practical and safety updates to the Android ecosystem exterior of main API stage releases and make new performance backward suitable on already-released Android variations. These enhancements assist make growth extra versatile and broaden the attain for app builders. We have constructed a brand new Extension SDK framework so that you can combine with these APIs, and at present, we’re releasing the primary public model of the Extension SDK (Extension Degree 4).
Sooner API and have introductions
Being able to introduce new performance exterior of main API stage releases permits sooner improvements. As shared in a previous post, starting this 12 months we plan to roll out the preliminary Privacy Sandbox on Android Beta release to Android 13 gadgets. You can begin utilizing the Extension SDK to combine your options with the AdServices APIs to arrange for restricted manufacturing testing. Learn more on how you can take part within the Privateness Sandbox Beta launch, and arrange your growth setting with a check gadget or emulator.
Backward compatibility
Verify for API availability
enjoyable isPhotoPickerAvailable(): Boolean { |
The choice verify, by way of Construct.VERSION.SDK_INT, would appear to be this:
enjoyable isPhotoPickerAvailable(): Boolean { |
This verify remains to be protected and proper, however this perform would return false on some gadgets the place the API is now accessible. In consequence, the SDK_INT verify just isn’t optimum, and the extension model verify is a greater solution to verify for API availability. All gadgets with SDK_INT >= 33 additionally have an R extension model of
>= 2, however there are gadgets with SDK_INT < 33 with R extension variations >= 2.
Equally, the AdServices API reference might point out that it’s “added in Advert Providers Extensions 4”. The Advert Providers extension makes use of the SdkExtensions.AD_SERVICES fixed. The supply verify seems like this:
enjoyable isAdServicesAvailable(): Boolean { |
For developer comfort, we’re extending Jetpack to make it simpler to work with extension variations. For instance, you should use a Jetpack library function to check for PhotoPicker availability, which abstracts away the conditional model checks. We count on to be releasing extra Jetpack libraries (such because the Privateness Preserving APIs within the Privateness Sandbox) to help the right use of APIs launched by way of Extension SDKs.
Tooling help
To assist guarantee app high quality, we added Extension variations tooling help to Android Lint’s NewApi verify. Since Android Studio Flamingo, it may auto-generate the right model checks for APIs which were launched by way of SDK extensions. Utilizing these new model checks is totally elective, however adopting them may assist result in extra widespread use of recent APIs after they exist.
Get familiarized with SDK extensions
We’re simply starting the SDK Extension developer journey and plan to make extra options accessible sooner or later. You will get the most recent SDK extension 4 accessible within the SDK Supervisor at present. Be taught extra concerning the SDK Extensions and our documentation on the Privacy Sandbox Beta and the photo picker.