Recently, I installed the new version of Android Studio called Flamingo. Prior to that, I used the Empty Activity
template to develop Android applications using the Java programming language. However, after installing the new version, I noticed that the default template has changed to Kotlin programming language, and I’m unsure if I can switch it back to Java.
Currently, I’m using the Empty Views Activity
template to build my Android applications using Java programming language.There is no detailed documentation available on this topic in the internet.I’m curious to know the differences between the Empty Activity
and Empty Views Activity
templates
2
Answers
In the Flamingo version, The template now uses
compose Material 3
by default unless they're specified asview templates
.Compose template(aka jetpack compose) is the best practice to create an Android app.Why compose template:
Jetpack Compose is a modern toolkit for building native Android UI. Jetpack Compose simplifies and accelerates UI development on Android with less code, powerful tools, and intuitive Kotlin APIs.
Note you won't be editing any XML layouts or using the Layout Editor. Instead, you will call composable functions to define what elements you want, and the Compose compiler will do the rest. The following are key takeaways from partners who have experienced the advantages of adopting Jetpack Compose:
Less Code: Jetpack Compose allows developers to achieve more with less code compared to using the traditional Android View system. Building buttons, lists, animations, and other UI components requires significantly fewer lines of code. This reduction in code improves productivity, simplifies testing and debugging, and minimizes the chances of introducing bugs.
Intuitive: Compose utilizes a declarative API, enabling developers to describe the UI they want, while the system handles the rest. The APIs are intuitive, easy to discover, and use. Building stateless components that are independent of specific activities or fragments makes them highly reusable and testable. The simplicity and maintainability of code written in Compose are commended.
Accelerated Development: Jetpack Compose is compatible with existing code, allowing developers to call Compose code from Views and vice versa. Popular libraries such as Navigation, ViewModel, and Kotlin coroutines seamlessly integrate with Compose. The interoperability and ease of integration make adoption flexible and gradual. Android Studio provides robust support, including live previews, enabling faster iteration and code deployment.
Powerful: Compose offers direct access to Android platform APIs and built-in support for Material Design, Dark theme, animations, and more. It simplifies the implementation of animations, making it easy to add motion and vitality to apps. Compose also provides the flexibility to implement custom designs, enabling developers to work with Material Design or their own design systems.
Source:
Empty Activity
is now a Composed template.Empty View Activity
is the old one.Source: https://developer.android.com/studio/releases#updates-to-npw-nmw
If you want the template to be in Java or Kotlin, you can select that on the next screen. Note that Compose only works with Kotlin, so there is no Java template option there.