Beginning Android Development with Kotlin, Part Two: Using Android Studio | raywenderlich.com

In this Android Studio tutorial, you’ll learn the fundamental concepts of developing with Android Studio using Kotlin by creating an app to read your fortune.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/738946-beginning-android-development-with-kotlin-part-two-using-android-studio

I don’t think that I’m a dump person but this course is making me feel that way. None of the code provided works. The views in the constraint layout won’t display properly. Basic activity creates an activity with multiple fragments, this tutorial doesn’t provide any detail on how to handle that. This is supposed to be a beginner tutorial but nothing past adding the crystal ball image actually works. I’ve restarted the project multiple times, I’ve gone though it word for word. It’s almost as if android has changed so much since this tutorial was written that this tutorial is no longer relevant.

I’m not sure what the actual issue is, but I do know that this tutorial caused more frustration than anything else. It’s hard to decide to purchase a subscription when the free tutorials don’t even work to begin with. I certainly hope this is just an issue on my end. Perhaps I’m doing something wrong without even knowing it.

Edit: I had to make an empty activity and manually fill in the views in a constraint layout in activity_main.xml to make mine appear like the tutorial shows. There is a ConstraintLayout tutorial on raywenderlich.com that’s free. Then I was able to use the code provided for the MainActivity.kt file but I also had to delete the lines regarding the toolbar. Make sure you import the Java Random and not the Kotlin Random. After building the app this way, it functioned as advertised and I was able to do the logcat portion of the tutorial.

I just downloaded the project from the download materials button and the project runs fine in all versions of Android Studio (both 3.6 and Canary versions). There are no fragments in this project, just one Activity. All the layouts open fine. What version of Android Studio are you using? Are you on Mac or Windows?

1 Like

Thanks for getting back to me.

I’m on Android Studio 3.6 on Mac. I’m not sure why, but whenever I crate a basic activity, i’m getting an activity with fragments.

I was able to make the app run, but I had to create a new empty activity and fill in the views manually in the activity_main.xml to get the app to appear similar to what the tutorial showed. Then in MainActivity.kt i was able to use your code but I had to delete the lines regarding the toolbar.

Once I had it working I was able to finish the logcat stuff and then play around by setting the crystal ball image as the clickable button and changing the image.

I spent over two days playing around with this tutorial trying to follow the steps provided. I’m still not sure why my basic activity makes something that has two fragments.

Now that you’ve explained what is going on, I understand a bit better. So, I thought the problem was that we are using a “Basic Activity” instead of an “Empty Activity” project. I tried both several times creating a new project and only had 1 activity and no fragments. I know that “Bottom Navigation Activity” and “Fragment + ViewModel” will create Fragments. Did you choose a different type than those 2?

1 Like

I just checked it again. I definitely had “Basic Activity” selected, but this is what Android Studio created for me. Screen Shot 2020-05-05 at 4.51.10 PM

I’ve got another picture for the next post to show you what happens when I try to use your xml code.

Edit: Apparently I’m limited to 3 replies and one image per post. When I posted your xml code over this code, all of the views were nested in the top left corner and they were tiny like a single pixel. The image wouldn’t show or anything.

Edit 2: I figured out what’s going on. My father happened to have Android Studio 3.5 on his PC and we tested creating a new “Basic Activity” on his machine. When we made a new project and used “Basic Activity,” we got a basic activity exactly as this tutorial shows. Then we updated his Android Studio from 3.5 to 3.6.3. At that point, when we created a new “Basic Activity” we got one with fragments just like the picture I posted above. This tutorial indeed does not work with Android Studio 3.6.3, but I posted instructions in my previous comments about how I was able to make the tutorial work anyway and finish the logcat section of this tutorial.

This tutorial is more than six months old so questions are no longer supported at the moment for it. Thank you!