I'm a self-taught developer and I don't have a lot of experience yet, but the last year has been really life-changing for me since I started getting into software development, specifically for Android applications.
Still, I would like to share what my first year as a developer has taught me with this community, and write about what I've learned and what I think are some important aspects to consider when getting started into Android development.
I'll be attaching some useful resources that have helped me.
In this post I will cover:
- Resources to get started.
- Considering different screen sizes.
- Programming languages (Java/Kotlin).
- Naming conventions for layout resource folders and class packages.
Please, if you're a more experienced developer or have a more complete knowledge of Android development and it's best practices, feel free complement and/or share how you agree or disagree with what I'm including in this post. Any comments that would help me or anyone reading this is welcome!
When I decided I wanted to develop mobile apps for Android, the first thing I did was to look for online courses. This approach is accessible, you can go at your own pace, and you can even skip some lessons if you don't feel like covering them at the time. I got recommended Udemy's The Complete Android Oreo Devloper Course. The course is great, it's for people who has zero coding experience (so it was perfect for me at the time), and even if you have experience, it's a great introduction into the Android environment. While I was taking the course I was also working on a side project, so it helped me a lot to apply the concepts I was learning into an actual application idea I had.
While I was watching the content of this course, I was also taking Java in Depth: Become a Complete Java Engineer! which helped me to get a deeper knowledge of the language and to not being stuck learning just the basics I needed for Android.
Other course that I can recommend, and that I'm taking on now it's Google's free Developing Android Apps with Kotlin, available in Udacity. This one requires a bit of previous programming experience and knowledge of Android Studio, but it's very straightforward and covers the fundamental topics to get started and develop apps.
YouTube videos and tutorials are also a great resource to learn specific features and implementations. There's almost always a video explaining how to do exactly what you want for your mobile app.
Getting stuck and having a hard time understaning some things is part of the process. I've learned that 95% of your questions have already been asked and answered in sites such as Stack Overflow, GitHub, or in the Official Android Developer documentation.
As you may know there are thousands of different phones that use the Android operating system. Even if you're aware of this, it may not be the first thing you consider when you're just getting started learning and building apps.
One of the first apps I made had a complex grid and some images on one of it's screens, and while I was building it I was testing it on my phone, so of course I was designing it so it would look good on MY phone.
When I uploaded it in a friend's phone, SURPRISE! I realized how horrible it looked on other devices, the grid and the images didn't even fit the screen and it was kind of embarrasing. That was the first time I struggled with srcreen sizes and realized that it's a VERY important factor to consider when building apps for Android. Be sure to choose the right ViewGroup(s) and design for different devices.
A ViewGroup is the container of the elements (Buttons, Texts, TextInputs, Images, etc.) in your screen and it's important to pick one according to how your content is going to be organized. Mixing a lot of ViewGroups or using them incorrectly can (and will) make your app look different (sometimes horrible) in other devices' screens that maybe you didn't considered while designing the UI.
Some of the most popular ViewGroups are:
- Linear Layout
- Relative Layout
- Constraint Layout
- Frame Layout
There are a lot more, which are used for other specific cases. Be sure to know them and choose the right one for your layout.
In Android Studio, you can pick several different devices to get and idea about how your UI will look in said device.
Other way to approach this issue is to generate up to 4 or 5 .xml files for the same layout to support different screen sizes.
For example, if you have a main_activity_layout.xml, you may have to create files such as: main_activity_layout.xml(mdpi), main_activity_layout.xml(hdpi), main_activity_layout.xml(xhdpi), etc.
This lets you to have different sizes for views, such as buttons, for the layout.xml(hdpi) than the size of the same button you have in layout.xml(xxhdpi). The app will identify the device's density and pick the layout file for said density.
Here's and example of how your layout files would look like in your res/layout folder:
Both are good for Android development, I've worked with both of them and each have it's pros and cons. However, if you're a total beginner in programming and/or Android development, this is what I, based on my short experiece, would recommend:
I began programming apps with Java, and I would recommend that if you're a beginner (like me) you do as well.
The main reason is that Java is still used a lot for Android development, and a lot of resources are still documented in it. It helped me a lot to find documentation, open source resources, and Stack Overflow answers for Android development topics in Java. So I think it's easier to get familiar with the whole Android environment when you find support for your doubts or documentation in the language you're using.
I recommend to learn and use Kotlin when you feel comfortable with basic functionalities and implementations for Android, such as handling buttons, listeners, using methods, creating classes and functions, etc.
The way I see it, Kotlin is the present and future of Android development. Most of the new documentation and tools are made and documented to be programmed with Kotlin. If you've watched the latest Android Dev Summits almost all of the content is explained in Kotlin, and most of the documentation is already updated to Kotlin.
A lot of job positions that I've seen are looking for developers who have worked with Kotlin or are at least interested in learning it.
Kotlin has proven to be a powerful languange that makes coding apps for Android faster and cleaner.
Having an organized project can be not 100% intuitive. If you're working on a big and complex project you don't want your clases to be al mixed one after another. Your classes have different funcionalities in your project, some may be simple Activities or Fragments, others handle your http requests, and others may be adapters for your LisViews, and so on...
You want your files to be organized, I'll share what I think it's a simple and effective approach to work on an organized project.
I personally like this organization where you have separate packages for Activities, Fragments, Adapters, API methods for http requests, and some Util classes for helper methods. This has helped me a lot to keep a more organized project and to know which classes I can reuse in different parts of my project.
The link above also covers what I've found is a good way to keep your layout files organized. Since you can't separate your layout files in packages or folders as in clases, keeping a simple convention of naming activity_your_activity_name.xml can help you find them easily if you have a lot of layout files.
I've found programming Android apps to be very fun and useful! I´ve really been enjoying myself in a way I've never had while working.
Almost everyone has a smartphone now and the idea of creating for any kind of person in the world is pretty exciting, either if it's a game or an organization app, or something that addresses a social issue or solves a problem in healthcare. The possibilities are infinite!
Being a self-taught developer, or trying to learn something by yourself is not easy, but it doesn´t have to be very hard either. Learn how YOU learn best, find support not only in communities and resources online, but also with friends or coworkers, there's nothing wrong in not knowing and/or struggling every once in a while. Remember that you're never the smartest person in the room, and if you are, then maybe you're in the wrong room.
Keep learning and happy coding!