A template project for the latest Android Studio with an added Scala 3 module.
Android Studio is currently quite opinionated towards Kotlin,
so a Java module is not an option you get straight from the New
> New Project…
menu.
If you want the same project starting from the Java-only template and then entirely converted to Scala 3, please check https://github.com/mcallisto/Scala-3-Android-Studio-Java-template.
Helping the adoption of Scala in Android Studio.
This is the project you get if:
-
in Android Studio Meerkat Feature Drop | 2024.3.2 you choose from menu:
New
>New Project…
>Empty Activity
(template for Phone and Tablet) -
you then add a minimal Scala 3.7.0 module named
core
and call it from theapp
module -
you use STTP to query ScalaDex and display the results. Credits and big thanks for this to @keynmol
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.
The Kotlin app
module is built using the official
Android Gradle Plugin (AGP).
The Scala 3 core
module is built with the official Gradle
Scala Plugin,
which is not compatible with AGP.