July 2, 2023

Android - Easy Kotlin tutorial

I am using Android Studio Flamingo. I have gotten somewhat "warmed up" with it with some other, pretty bad, tutorials. This one looks good (from "Android Authority" in April 2021), so here we go. They say we will build a quiz. I type "studio" to launch Android studio. It resumes an old project, so I use File - New - New Project and away I go. I select "Empty Activity" and call the project "Quiz". It will put it in /home/tom/AndroidStudioProjects/Quiz. I stick with SDK for API 24 (Android 7.0). For whatever reason, this is the default.

The tutorial doesn't say anything about this, but I go to Tools - SDK Manager and verify that the SDK for API 24 is not installed. I select it, and type Apply and it wants me to confirm the download (108M estimated for the download, 410M on disk). Away it goes. The SDK will download to /home/tom/Android/Sdk.

Android Studio is giving me a complex template using JetPack Compose, not the traditional template that the tutorial shows. So I just delete it all and replace it with what the tutorial has. I'll note that the tutorial shows this:

class MainActivity : AppCompatActivity() {
But the autogenerated code shows this:
class MainActivity : ComponentActivity() {
The tutorial also talks about activity_main.xml as a layout file and tells me that android studio will have this open for me (which it does not). I just ignore the missing xml file for now and hit the green "build and run" arrow, hoping it will complain about the missing xml file, but I get errors like:
OnCreate overrides nothing
unresolved reference setContentView
So I am giving up this tutorial as hopelessly incompatible with the current android studio, at least at my current level of knowledge.
Have any comments? Questions? Drop me a line!

Adventures in Computing / [email protected]