This is a belated review of Google I/O 2023 for Android Developers.
Do you remember how AlphaGo amazed the world in 2017, sparking the first wave of AI frenzy in nearly 20 years? At that year’s I/O conference, Google announced a strategic shift from Mobile First to AI First. The emergence of ChatGPT at the end of last year was like the secondary ignition of the AI rocket, prompting major tech companies worldwide to invest heavily. Google has also invested more resources into the AI field, integrating more internal resources, and this year’s I/O conference opening spent most of its time discussing AI.Due to the extensive coverage of AI, Android developers seem to feel a bit neglected, but there are still updates related to Android development.This article will summarize the technical updates related to Android developers before and after I/O.
Jetpack Compose
According to Google data, 24% of the top 1000 apps on Google Play use Compose. Compose has been well promoted over the years, and both performance and ecosystem have seen significant improvements.
Material 3
Firstly, Material 3 is the latest implementation of Google’s recommended Material Design style. It has recently become more refined. New components such as bottom sheets, date-time pickers, and search functionality have been added.A large number of core components have entered a stable stage, and a lot of user interaction support has been added. For more information, you can refer to the official introduction video:https://www.youtube.com/watch?v=tu0UtDGC31Ad
Support for Multiple Screens
Google hopes that Jetpack Compose can become the UI development framework for all Google platforms, not just mobile, but also TV, Wear OS, etc. Additionally, new hardware devices like the Pixel Fold also require UI adaptation. Therefore, extending Compose to multiple screens is an important direction for Compose in the near future.
At this year’s I/O conference, Google first announced that Compose for TV has entered the Alpha stage.Now, most domestic smart TVs are based on the Android system, and if Compose for TV enters a stable stage, developers can significantly increase efficiency in TV app development and can more efficiently port apps developed on mobile based on Compose to Android TV. In addition, Compose for Wear OS version 1.1 has also entered the stable stage, and the upcoming version 1.2 has already entered the Alpha stage.
In the past two years, Android widgets seem to have regained attention from users, phone manufacturers, and developers. The Compose-Style API for widget UI development – Glance, has also entered the Beta stage this year. Developers can gradually abandon the difficult-to-use RemoteView in subsequent development, thus experiencing the pleasure of declarative programming.
Android Studio
Android Studio will also receive comprehensive upgrades in the upcoming new version. Due to numerous and detailed updates, here are a few important major updates:
Studio Bot
With the recent popularity of AI large language models, Android development cannot be left behind. Android Studio has added a new feature called Studio Bot, allowing developers to ask Studio Bot questions while writing code. Studio Bot can answer questions or provide example code just like ChatGPT. Studio Bot is developed based on Google’s own PaLM 2 large language model, and Google claims that Studio Bot is still in a very early stage, and the model is still being trained. Studio Bot is available in the preview version of the HedgeHog version. I was looking forward to installing Android Studio HedgeHog for testing, but the result was:
Studio Bot is currently only available in the US, so you need a US Google account to test it. However, based on some demos in the official demonstration video, the performance looks quite good:
The screenshots cannot fully display, but Studio Bot often provides example code for the answers to questions, and I believe that once it enters a stable stage, it will be very helpful for daily development.
Foldable and Tablet Device Emulator
Corresponding to Google’s multi-screen plan, it provides developers with a more convenient way to test their applications’ compatibility on foldable phones and tablets. Similarly, in the Android Studio HedgeHog version, you can create emulators for different screen sizes like Pixel Fold in Device Manager:
Local Device Mirroring and Android Device Streaming
Emulators are convenient, but applications in a production environment usually require sufficient testing on real devices. However, developers often have inconveniences when switching between testing machines and using a mouse and keyboard for development. In the past, developers often used open-source projects like Scrcpy to mirror their phone screens to their computer screens, allowing them to operate real devices like emulators without losing fidelity while staying on the computer. Now, Android Studio has a built-in mirroring feature (Device Mirroring) available in the HedgeHog version. Of course, Device Mirroring also supports Wear OS devices.
Device Mirroring requires developers to have the necessary device type in hand, but developers (usually individual developers) cannot always own the latest flagship models. So how can they test their applications’ compatibility on these models? Android Studio is about to launch the Android Device Streaming service, providing developers with the latest Google Pixel physical devices for remote connection, all done within Android Studio without leaving the current window.
New Intellij IDEA Platform
As we all know, Android Studio is developed based on JetBrains’ Intellij IDEA, and usually, each version corresponds to a version of Intellij IDEA. This means that when the Intellij IDEA platform upgrades, new features are usually guaranteed to be available in Android Studio as well. Android Studio HedgeHog is developed based on the Intellij IDEA 2023.1 release version, gaining more features and performance improvements while also supporting the new UI style of Intellij IDEA. Of course, there is a switch for this, and developers can choose to turn it on or off:
This only introduces some updates to Android Studio features. New features such as Live Edit and enhanced support for Kotlin Gradle DSL are welcome for developers to explore themselves.
Kotlin in Android
According to Google data, 95% of the top 1000 apps on Google Play currently directly or indirectly use Kotlin. In addition to introducing Kotlin to Android, Google has also developed core tools such as the Kotlin compiler. Google has even significantly introduced Kotlin into its server-side code. For Android developers, there are four major events related to Kotlin that need attention this year:
Kotlin 2.0 Compiler (K2)
This is the new compiler that Kotlin has been developing for many years, which will be enabled by default in the Kotlin 2.0 version. Compared to Kotlin 1.8, it will improve the speed of compiling Kotlin code by more than 2 times. In addition to the improvement in compilation speed, K2 will also bring more new syntax features, so stay tuned.
Kotlin DSL Will Become the Default Choice for Gradle Build Scripts
This year, Gradle announced that Kotlin DSL will replace Groovy as the default scripting language for Gradle scripts. Google is also following this announcement, and in the future, when creating new Android projects in Android Studio Giraffe, KTS will be used as the default build script. From now on, Android developers will use the same language for both writing Android code and build scripts. Compared to Groovy, KTS, being a strongly typed language, has excellent API association and IDE highlighting features, helping developers to get better code hints while writing Gradle build scripts to improve development efficiency.
Kotlin Symbol Processor (KSP)
KSP is entirely developed by Google, and Android developers can use KSP for high-speed code processing and generation, replacing the original KAPT tool. Compared to KAPT, KSP has features such as 2 times processing speed, better type design, and availability in a multiplatform environment. Currently, official Google projects like Room and Glide have migrated to KSP, and the migration of Dagger and Hilt is also in progress. Google has also released a tutorial for migrating to KSP: https://developer.android.com/build/migrate-to-ksp
Kotlin Multiplatform in Google
Kotlin Multiplatform is a cross-platform technology that compiles Kotlin into different platform products using different Kotlin compilers. Google has significantly introduced Kotlin Multiplatform technology into its own product Google Workspace. Additionally, annotations, collections, and DataStore in Jetpack have released Alpha versions that support Kotlin Multiplatform environments. Google has also officially launched a Kotlin Multiplatform page in the documentation:https://developer.android.com/kotlin/multiplatform
Android 14
Finally, we arrive at the annual update of the Android system. The updates for Android 14 are numerous, with the latest version being Android 14 Beta 3. Here, I will only pick a few updates that I believe are the most important so far; for details, you can refer to Google’s official information.
In recent years, the focus of Android system updates has been on user privacy and security, with each version update bringing stricter restrictions on user data and permissions for app usage.
New Permissions for Accessing User Albums and Media Files
When Android 13 was launched, two new permissions were added: READ_MEDIA_IMAGES and READ_MEDIA_VIDEO, to protect against potential access to user media files when apps go into the background or are manually killed by users. Android 14 introduces a new permission READ_MEDIA_VISUAL_USER_SELECTED to replace the above two old permissions. In Android 14, a new option for accessing media resources has been added: “Select Photos and Videos,” which allows applications to only access the media resources selected by the current user. In Android 14, if the READ_MEDIA_VISUAL_USER_SELECTED is not adapted, when applying for the old READ_MEDIA_IMAGES or READ_MEDIA_VIDEO permissions, if granted by the user, the app can still get a PERMISSION_GRANTED result, but the app can only access the user-selected media resources. If the app goes into the background or is killed by the user, the permission will be revoked by the system, and the next time the same access is made, permission will need to be requested again.
Foreground Services Type Must Be Specified
Foreground Services, introduced in Android 12, display in the phone’s notification bar to inform users that the app is still running on the system and consuming resources (common in music and podcast apps). In Android 14, Foreground Service must declare its type to indicate its purpose. For example, health apps need to declare as FOREGROUND_SERVICE_TYPE_HEALTH, while services using location data in the background must declare as FOREGROUND_SERVICE_TYPE_LOCATION.
Restrictions on Broadcast Receivers
After Android 14, if developers dynamically register a broadcast receiver, they must declare whether it is exposed to the outside (RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED), unless it is registered only as a system broadcast receiver. If you want to use an intent to start a non-exported component, you must use an explicit call and implicit calls will no longer be supported.
OpenJDK 17 Upgrade
Support for OpenJDK versions is a significant issue for Android, as developers often complain about not being able to use the latest features of JDK. In Android 14, the latest release of OpenJDK 17 LTS has been supported. However, considering compatibility issues with older Android systems, there is still a long way to go before developers can freely use the features of OpenJDK 17.
Conclusion
Due to space constraints, this article cannot cover all the details related to Google I/O and Android development. Many upgrades related to Google or Android functions, such as Android Health, Google Play, Google Wallet, etc., have not been mentioned here. Developers with overseas needs can search for relevant information on the official Google I/O website, which includes many wonderful official presentations.
Although Android occupied a small portion of the opening speech at the I/O conference, upon careful review, numerous upgrades to the Android system have brought higher privacy and security for users. Meanwhile, the upgrades to various developer tools have also significantly enhanced the development efficiency for app developers.
Leave a Comment
Your email address will not be published. Required fields are marked *