Android Activity not building

Hello all,

I am trying to work on the second activity, the cheat activity. Every time I try to build it as per the book, nothing happens. I right click on app/java as the instructions want me to and select new empty views activity. I did this since there was no empty activity as originally prescribed in the book. At that point, I get a window that looks very similar to the instructions so I tried to name it as it said in the instructions. It is at this point that I see the program doing something but nothing is built. I do not have a new cheat activity, a new cheat activity layout(activity_cheat.xml) or anything that the book lists. As for troubleshooting steps, I have attempted the following:

Restarted the program.
Reviewed the layout directory in file explorer and in the application. (Only shows the main activity layout and not the newly created layout)
Tried to re-do the process several result and got the same result
Restarted my computer.
I have also verified that I am selecting the com.bignernrach.android.geoquiz as the instructions specify as well. This changed nothing.

Is there something I am missing or need to do? The IDE is not building anything as the book is describing it.

There could be a few things that are the issue here. Could you share a screenshot of the files in your project? Maybe we can find CheatActivity.kt and activity_cheat.xml somewhere in there.

If you wish a screenshot from a different directory, please let me know. Thanks for your help.

Those screenshots are helpful. It looks like those files aren’t there, so we’ll need to add them in by hand. The stuff that you tried (New Empty Views Activity) should work, but things can always get a little wonky.

In order to create activity_cheat.xml, you need to create a new layout file. Right click the folder in this screenshot and then do NewLayout Resource File. Put in activity_cheat.xml as the name and everything else should be good.

0e20da17fe8acd72b9ef133c34c2aa273d8d357f copy

You should see all the code you need in the file in Listing 7.2.

In order to create CheatActivity.kt, you will go through the same steps of creating any Kotlin file. Right click the folder in this screenshot and then do NewKotlin File/Class.

0e20da17fe8acd72b9ef133c34c2aa273d8d357f

You should see the majority of the code you need there in Listing 7.3. (You will still need the package line and any import lines as well up above, but Android Studio should include them automatically for you).

I hope this helps.