Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Android Programming for Beginners

You're reading from   Android Programming for Beginners Build in-depth, full-featured Android apps starting from zero programming experience

Arrow left icon
Product type Paperback
Published in Apr 2021
Publisher Packt
ISBN-13 9781800563438
Length 742 pages
Edition 3rd Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
John Horton John Horton
Author Profile Icon John Horton
John Horton
Arrow right icon
View More author details
Toc

Table of Contents (30) Chapters Close

Preface 1. Chapter 1: Beginning Android and Java 2. Chapter 2: First Contact: Java, XML, and the UI Designer FREE CHAPTER 3. Chapter 3: Exploring Android Studio and the Project Structure 4. Chapter 4: Getting Started with Layouts and Material Design 5. Chapter 5: Beautiful Layouts with CardView and ScrollView 6. Chapter 6: The Android Lifecycle 7. Chapter 7: Java Variables, Operators, and Expressions 8. Chapter 8: Java Decisions and Loops 9. Chapter 9: Learning Java Methods 10. Chapter 10: Object-Oriented Programming 11. Chapter 11: More Object-Oriented Programming 12. Chapter 12: The Stack, the Heap, and the Garbage Collector 13. Chapter 13: Anonymous Classes – Bringing Android Widgets to Life 14. Chapter 14: Android Dialog Windows 15. Chapter 15: Arrays, Maps, and Random Numbers 16. Chapter 16: Adapters and Recyclers 17. Chapter 17: Data Persistence and Sharing 18. Chapter 18: Localization 19. Chapter 19: Animations and Interpolations 20. Chapter 20: Drawing Graphics 21. Chapter 21: Threads and Starting the Live Drawing App 22. Chapter 22: Particle Systems and Handling Screen Touches 23. Chapter 23: Supporting Different Versions of Android, Sound Effects, and Spinner Widget 24. Chapter 24: Design Patterns, Multiple Layouts, and Fragments 25. Chapter 25: Building a Simple Image Gallery App 26. Chapter 26: Advanced UI with Navigation Drawer and Fragment 27. Chapter 27: Android Databases 28. Chapter 28: A Quick Chat before You Go 29. Other Books You May Enjoy

Examining the logcat output

In the previous chapter, we mentioned that our app was running in debug mode on the emulator or real device, so we can monitor it and get feedback when things go wrong. So, where is all this feedback then?

You might have noticed a whole load of scrolling text at the bottom of the Android Studio window. If not, click on the Logcat tab, as shown by the highlighted area labeled 1 in the next figure:

Note

The emulator must be running, or a real device must be attached in debugging mode, for you to see the following window. Furthermore, if you restarted Android Studio for some reason and have not executed the app since restarting, then the Logcat window will be empty. Refer to the first chapter to get the app running on an emulator or a real device.

Figure 2.1 – The Logcat tab

Figure 2.1 – The Logcat tab

You can drag the window to make it taller, just like you can in most other Windows applications if you want to see more.

This window is called logcat or is sometimes referred to as the console. It is our app's way of telling us what is going on underneath what the user sees. If the app crashes or has errors, the reason or clues to the reason will appear here. If we need to output debugging information, we can do so here as well.

Note

The app we are building should not have any problems at this stage, but in the future, if you just cannot work out why your app is crashing, copying and pasting a bit of text from logcat into Google will often reveal the reason.

Filtering the logcat output

You might have noticed that most if not all of the contents of logcat is almost unintelligible. That's OK. For now, we are only interested in errors, which will be highlighted in red, and the debugging information, about which we will learn next. So that we see less of the unneeded text in our logcat window, we can turn on some filters to make things clearer.

In the previous figure, I highlighted two more areas, as 2 and 3. Area 2 is a drop-down list that controls the first filter. Left-click it now and change it from Verbose to Info. We have cut down the text output significantly. We will see how this is useful when we have made some changes to our app and redeployed it. We will do this after we have explored the code and the assets that make up our project. Also, double-check in the area that is labeled 3 that says Show only the selected application. If it doesn't, left-click on it and change it to Show only the selected application now.

Now we can look at what Android Studio automatically generated for us and then we can set about changing and adding to the code to personalize it beyond what we got from the project creation phase.

You have been reading a chapter from
Android Programming for Beginners - Third Edition
Published in: Apr 2021
Publisher: Packt
ISBN-13: 9781800563438
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime