Skip to content

mcallisto/Scala-3-Android-Studio-Java-template

Repository files navigation

build_ci

Android Studio Scala 3 project, translated from Java

A template project in Scala 3 for the latest Android Studio translated from Java.

What about a Kotlin template instead, with a Scala 3 module?

Android Studio is currently quite opinionated towards Kotlin, so a Java module is not an option you get in the New > New Project… menu.

If you want to use Scala 3 together with Kotlin, starting from the standard Kotlin template, please check https://github.com/mcallisto/Scala-3-Android-Studio-Kotlin-template.

Aim

Helping the adoption of Scala in Android Studio.

This is the Scala project you get if:

  1. in Android Studio Meerkat Feature Drop | 2024.3.2 you create an app module with the Fragment + ViewModel template.

  2. you then add a minimal Scala 3.7.0 module named core and call it from the app module

  3. you use STTP to query ScalaDex and display the results. Credits and big thanks for this to @keynmol

  4. you translate to Scala the activity, fragment and model Java code in the app module

Notes

Why Scala 3.7.0?

Because is the first Scala version shipping scala/scala3#22632. The emitted Scala code is more compatible with Android ART.

Since currently all Scala libraries are not yet published to Maven Central with this version, the workaround is to let Android R8 minify the code, so minifyEnabled true must be set even for debug builds.

Building Scala with Gradle

In this project two different solutions coexist:

  1. The app module is built using the scala-android-plugin, which is brilliantly designed to work with the official Android Gradle Plugin (AGP).

  2. The separate core module is built with the official Gradle Scala Plugin, which is not compatible with AGP.

About

Template for an Android Studio project in Scala 3

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published