dachristenson

dachristenson

Kotlin and Android Development featuring Jetpack: No activity_main.xml anymore

I just bought this book to learn about Android development, and I’m already running into a major issue in Ch. 1, p. 20: “Update activity_main.xml”. Following the instructions, I was able to build and run the project until this point on my Samsung tablet and in the emulator. However, this paragraph starts out mentioning activity_main.xml and also layout_main.xml, neither of which were created by Android Studio when creating the project.

I did some googling and found that, apparently, as of Android Studio 2022.2 Flamingo released in April 2023, Google changed from using XML to define the layout to using Kotlin only with “Jetpack Compose”. However, I found suggestions from other users that all they needed to do to use the old way was to add activity_main.xml to …/res/layout. After that, they claimed that it worked as before.

So, I tried this, creating …/res/layout/activity_main.xml exactly as described on p. 24 and re-writing MainActivity.kt exactly as described on p. 26. The project builds and loads “successfully” (per Android Studio’s messages) on my Samsung tablet, but all it does is show a white screen for a fraction of a second before crashing. I tried with the emulator, and it did the exact same thing! Unable to find where I went wrong, I re-created the entire project under a different name and followed the book exactly, hoping to fix whatever error I couldn’t see. However, the new project behaves exactly as before. On both real tablet and emulator, trying to launch the app two or three times brings up a message about how Penny Drop (or other name) keeps crashing and asking me if I want to force close it.

I then downloaded the provided project code from the book’s website and tried that, but it won’t even build! Android Studio gives me several errors when I try to do so. The fact that Google apparently so radically changed Android (or at least Android Studio) in the rather short time since this book was printed – and didn’t even provide tools to recognize that it was an “old” project and update it to run – is quite frustrating.

Could you offer any suggestions on how to get past these issues and enjoy (and learn from) the rest of this book, please? Thanks in advance!

Popular Prag Prog topics Top

raul
Hi Travis! Thank you for the cool book! :slight_smile: I made a list of issues and thought I could post them chapter by chapter. I’m rev...
New
Chrichton
Dear Sophie. I tried to do the “Authorization” exercise and have two questions: When trying to plug in an email-service, I found the ...
New
leba0495
Hello! Thanks for the great book. I was attempting the Trie (chap 17) exercises and for number 4 the solution provided for the autocorre...
New
AndyDavis3416
@noelrappin Running the webpack dev server, I receive the following warning: ERROR in tsconfig.json TS18003: No inputs were found in c...
New
jskubick
I think I might have found a problem involving SwitchCompat, thumbTint, and trackTint. As entered, the SwitchCompat changes color to hol...
New
jskubick
I’m under the impression that when the reader gets to page 136 (“View Data with the Database Inspector”), the code SHOULD be able to buil...
New
brunogirin
When installing Cards as an editable package, I get the following error: ERROR: File “setup.py” not found. Directory cannot be installe...
New
oaklandgit
Hi, I completed chapter 6 but am getting the following error when running: thread 'main' panicked at 'Failed to load texture: IoError(O...
New
hazardco
On page 78 the following code appears: <%= link_to ‘Destroy’, product, class: ‘hover:underline’, method: :delete, data: { confirm...
New
SlowburnAZ
Getting an error when installing the dependencies at the start of this chapter: could not compile dependency :exla, "mix compile" failed...
New

Other popular topics Top

wolf4earth
@AstonJ prompted me to open this topic after I mentioned in the lockdown thread how I started to do a lot more for my fitness. https://f...
New
New
AstonJ
We have a thread about the keyboards we have, but what about nice keyboards we come across that we want? If you have seen any that look n...
New
AstonJ
There’s a whole world of custom keycaps out there that I didn’t know existed! Check out all of our Keycaps threads here: https://forum....
New
AstonJ
I have seen the keycaps I want - they are due for a group-buy this week but won’t be delivered until October next year!!! :rofl: The Ser...
New
AstonJ
In case anyone else is wondering why Ruby 3 doesn’t show when you do asdf list-all ruby :man_facepalming: do this first: asdf plugin-upd...
New
PragmaticBookshelf
“A Mystical Experience” Hero’s Journey with Paolo Perrotta @nusco Ever wonder how authoring books compares to writing articles?...
New
rustkas
Intensively researching Erlang books and additional resources on it, I have found that the topic of using Regular Expressions is either c...
New
AstonJ
If you want a quick and easy way to block any website on your Mac using Little Snitch simply… File > New Rule: And select Deny, O...
New
husaindevelop
Inside our android webview app, we are trying to paste the copied content from another app eg (notes) using navigator.clipboard.readtext ...
New

Latest in PragProg

View all threads ❯