How to Self-Learn Android Programming?

How to Self-Learn Android Programming?

Source: http://gityuan.com/

Many people ask how non-professionals can learn programming. In fact, even professionals mostly rely on self-study. There is a saying: “A master leads you to the door, but the rest is up to you.” No matter how great a teacher is, what they can teach you is very limited; true mastery comes from oneself. I studied mathematics for my undergraduate degree, and although my graduate studies were in computer science, graduate programs often focus on research and do not cover basic programming. Everything I learned about programming was through self-study. I started learning about Android when I began working.

As for the levels of learning, many people often categorize them into beginner, intermediate, advanced, and so on. Here I will simply divide it into two levels: Basic and Advanced. Additionally, all the books mentioned in this article are classic ones that I have read during my learning process, and I recommend them to everyone.

1. Basic Level

Reading posture: During the learning process, everyone often needs to read books. A quick search online will yield a plethora of recommended books. Faced with so many options, how should one choose and read? For books at the same level, choose one for in-depth reading while skimming through the others; they are mostly similar. The book chosen for in-depth reading should be read repeatedly.

1.1 Java Section

Java is the foundation of Android. I recommend that beginners first learn the basics of Java before moving on to Android. Take it step by step; don’t be impatient. Only with a solid foundation can you build a sturdy upper structure.

Java Books

  • Thinking in Java: The Chinese version is “Java Programming Thought.” This is a very classic Java book. Many people say it is not suitable for beginners, but I remember that the first Java book I read was this one. After reading it once, I gained an overall understanding of Java, but many details were not fully grasped. After checking resources, I read it a second time and gained a deeper understanding of Java. Later, after improving my skills, I picked it up for a third read and found that I had a deeper understanding of object-oriented programming. This book is suitable for repeated reading.

  • Effective Java: An advanced Java book that presents 78 specific recommendations for Java, offering unique insights into the intricacies of the Java platform and providing excellent code examples. This book is very beneficial for advancing Java skills.

  • Java Concurrency in Practice: The Chinese version is “Java Concurrency Programming in Practice.” This book explains concurrency programming step by step, starting from basic theories, discussing structured concurrency applications, performance and testing, and finally covering advanced topics like explicit locks, atomic variables, and non-blocking algorithms. It’s a great book for Java concurrency.

  • Java Performance: The Chinese version is “Java Performance Optimization Authority Guide,” a classic book recommended by Java’s father, James Gosling. It covers algorithm structures, memory, I/O, and disk usage methods, with easy-to-understand content and numerous monitoring and measurement tools. Optimization is a deeper field, and after gaining some Java foundation, it’s essential to understand this.

Java Virtual Machine – this is essential knowledge for advanced Java experts:

  • The Java Language Specification, official Java documentation (English version)

  • The Java® Virtual Machine Specification, official JVM documentation (English version)

  • Understanding the Java Virtual Machine: This is a comprehensive book on the Java Virtual Machine from a domestic perspective, covering everything from Java GC to internal implementations and optimization strategies. A must-read for Java experts.

The focus of this article is on how to learn Android, so I’ll include both the basic and advanced Java books in the basic section for Android learning. As an Android developer, there is no need to have an in-depth understanding of Java from the start; just reading one or two basic Java books, mastering the core essence of object-oriented programming, and understanding basic syntax is sufficient to begin learning Android. After gaining some understanding of Android, one can gradually improve both Java and Android skills.

I have friends who privately message me (Editor WeChat: AMEPRE) saying they find the Java books a bit difficult, possibly because I had read some introductory C and C++ books before tackling Java. If you are truly a beginner with no background in programming and wish to use Java as your entry language, you might want to start with “Java Programming Design” (basic level) or “Java from Entry to Mastery” to grasp the basic syntax. When you encounter unfamiliar methods, refer to the API documentation, and you’ll gradually become familiar.

1.2 Android Basic Level

Once you have a basic understanding of Java (you don’t need to be proficient), you can start learning Android. I recommend that beginners set up their development environment first, preparing the JDK and Android Studio. While reading, write sample programs to reinforce your understanding and improve your hands-on skills.

  • “Crazy Android Lecture Notes”: Author Li Gang. This was the first Android book I read, and it’s now in its third edition. I read the second edition based on Android 4.2. The book contains numerous examples, and I remember typing out each example after reading it. It took me about a week to finish the book while typing out most of the example code.

For basic Android books, one or two are sufficient; there’s no need to read too many foundational texts. Different skill levels require different pursuits, so I won’t introduce other basic books here. Additionally, during Android development, you will often need to download various development environments and tools. I recommend a great website, AndroidDevTools.cn, which collects various tools related to Android development and design. It’s comprehensive and fast, and most importantly, you can download the latest tools without needing to bypass the Great Firewall.

1.3 Primary Android Resources

What are primary Android resources? They are the official materials provided by Google, which are often in English and highly valuable. If your English is decent and you have a VPN, I strongly recommend you read the Android official materials directly. Don’t be intimidated by the English; many technical terms, such as Activity/Service, are already in English, and the remaining syntax is quite basic. If you don’t understand something, you can always translate it. I generally use Chrome with Google Translate to translate phrases on the fly.

In summary, if you can read and understand the following materials, you may not need to refer to the books mentioned earlier, and you will already be quite familiar with Android:

  • developer.android.com: The official Android development website. Below are some commonly used resources:

    • Additionally, Hu Kai initiated a Chinese version of the Android training course, translating the official documentation.

    • Android Training: Android training documentation;

    • Android API Guide: Introductions to Android components, Manifest configuration files, animations/images, etc.;

    • Android Tools: Documentation for various tools related to performance, testing, Android Studio, etc.;

    • source.android.com: Introduces open-source content related to Android;

  • Android Performance Patterns: A series of videos released by Google on YouTube in 2015 regarding Android performance optimization, currently updated to season 4.

    • The Chinese version of Android Performance Patterns Season 4 is available on Youku, organized by a domestic Google group;

    • Additionally, Hu Kai initiated a Chinese version of the Android performance optimization documentation, translating and organizing the official videos.

  • android-developers.blogspot.com: The official Android blog, which features some excellent updates.

1.4 Organizing Android Resources

By now, you should have the skills to develop apps. You should write your own apps and look at how other excellent apps are written. Below are some open-source libraries, tools, and apps:

  • android-arsenal.com: Curated by author vbauer, this site collects various open-source libraries and tools from GitHub, providing a search function and is the most comprehensive library available;

  • Android Open Source Project Summary: Curated by author Trinea, this site compiles various open-source libraries and is the most comprehensive one available domestically;

  • codeKK Open Source Project Source Code Analysis: Analyzes popular open-source frameworks from the perspective of source code;

  • codota.com: A code search engine that collects excellent sample Java code for various APIs.

Of course, there are many other excellent blogs and websites worth recommending… //TODO

2. Advanced Level

As a programmer, merely reading source code and looking at API documentation is far from enough. The most effective way to enhance your skills is to read source code directly, not just the Android system source code but also various excellent open-source libraries.

2.1 The Importance of Reading Source Code

To quote Linus Torvalds, the father of Linux: Read the fucking source code. Whether you are reading Android system source code or excellent open-source frameworks, it will greatly enhance your capabilities. Firstly, you can learn excellent coding styles and design philosophies; you can truly understand not just how things work but also why they work; and you can guide yourself to use APIs more flexibly and find system bugs more quickly.

2.2 Preparing to Read Source Code

  1. Java Basics: The upper layer framework and app layer use Java syntax;

  2. C/C++ Basics: The JNI/native layer of Android code uses C++; Linux uses C;

  3. Linux: The Android kernel is based on Linux, so understanding Linux-related knowledge is necessary to master Android deeply.

  4. Git: Android source code is managed using Git and repo;

  5. Make: Android source code is compiled using a Make system, and you will see many files like Android.mk;

  6. Source Insight: This is an essential tool for reading source code; it allows seamless switching between Java, C++, and C code;

  7. Eclipse: Familiarity with common shortcuts is crucial; while Source Insight is very convenient, I prefer using Eclipse for Java framework code due to my familiarity, while I use Source Insight for native and Linux code;

  8. Android Studio: This is the official app development environment supported by Google, with tutorials available;

  9. Google Drawings: This is a drawing tool; many articles on the Gityuan blog are created using Google Drawings, such as the diagrams in the Binder article.

  10. StarUML: This is used for class diagrams; the class and flow diagrams in Gityuan’s blog articles are created using StarUML.

2.3 The Approach to Reading Source Code

Reading source code is not about going through files in order from the first line to the last. The correct and efficient way to read source code is to start from a main line and trace back from the top layer to the bottom, moving back and forth between various modules, files, and methods, reading repeatedly to clarify the entire logical flow. Always approach reading with thought; try to discern the author’s intentions, understand the intricacies of the code, think about potential flaws, and summarize excellent design philosophies.

Below are the libraries I often refer to while reading Android source code:

Reading Android Source Code:

Here is a flowchart of the Android boot process that I used in internal company presentations, which I have shared multiple times. It represents the entire Android architecture:

Click to view the full image

How to Self-Learn Android Programming?

Android System Source Code

android.googlesource.com: This is the official Google source code repository, which cannot be accessed directly from within China and requires a VPN. For a programmer, it is essential to have the ability to bypass the Great Firewall. The Android source code contains numerous libraries. Below are some libraries I frequently refer to while examining the Android source code:

  • android/platform/packages/apps: Android’s built-in apps, such as Email, Camera, Music, etc., are the directories mainly of concern for application developers;

  • android/platform/frameworks/base: Java framework, this is the directory most frequently reviewed by framework engineers;

  • android/platform/frameworks/native: Native framework;

  • android/platform/art: Art virtual machine;

  • android/kernel/common: Android kernel, the module most focused on by driver engineers;

  • android/platform/system/core: Core system;

  • android/platform/libcore: Platform lib library; additionally, for those unable to bypass the firewall, you can download the Android source code via GitHub, which is periodically synced from the official Google source code repository.

2.4 Excellent Resources

Newton once said: “If I have seen further, it is by standing on the shoulders of giants.” This saying is very practical. After reviewing the previous content, don’t rush into the world of source code; be cautious not to fall into chaos and ultimately abandon your quest for knowledge. Always make good use of existing excellent resources.

Android System Source Code Analysis

  • Innost’s column

    • Blog by senior Deng Fanping, which is well-organized and covers most of the Android system content;

    • “In-Depth Understanding of Android” (Volume I, Volume II, Volume III)

  • Old Luo’s Android Journey

    • Blog by senior Luo Shengyang, introducing the Android system from various perspectives;

    • “Analysis of Android System Source Code Situations”

  • Gityuan Source Code Analysis

    • Blogs by Deng Fanping and Luo Shengyang are based on Android 2.x or 4.x, while Android has now developed to Android 6.0. Regardless of how Android changes, its core thinking remains largely unchanged, so their blogs are still worth studying and referencing. That said, Android has gone through several major version iterations, with many changes in code structure and overall logic. Therefore, the author plans to write a series of articles on Android 6.0 source code.

    • As a newcomer in the Android field, Gityuan may not be as capable as many seniors, but possesses a heart for sharing, a passion for Android, and a persistent attitude, always striving on the path of improvement.

2.5 Advanced Books

  • Understanding the Linux Kernel

  • In-Depth Linux Kernel Architecture

  • Linux Kernel Design and Implementation

  • Linux Device Drivers

  • Refactoring: Improving the Design of Existing Code

  • Programming Pearls (Volume 1, Volume 2)

  • Design Patterns

  • Zen of Design Patterns

  • The Mythical Man-Month

The first four books are about Linux; if you are not looking to engage in Linux-related development but want to enhance your overall understanding of Android, reading one or two of them is sufficient. Familiarity with Linux processes, memory, I/O, and drivers, as well as CPU scheduling and inter-process communication, will be adequate. Additionally, many excellent books exist; here I only introduce/list those I have read, and I am currently reviewing more excellent texts, which I will update later.

3. Other

Additionally, I recommend checking out the diycode initiative, a collaborative effort by a group of active Android community members (including myself) to write a recommended book on Android development.

Finally, let’s touch on a side note about learning programming:

  • Curiosity takes you further than ambition: Many people have grand ambitions for the future, but it’s often a genuine curiosity for technology and a desire to explore, combined with persistence, that leads to success.

  • Have an open mindset: I used to keep my thoughts and findings in my cloud notes without organizing them, which isn’t conducive to technical development. It’s essential to organize your scattered knowledge and share valuable insights in the form of blog posts, which is another way to enhance your skills. Moreover, while focusing on technology, it’s crucial to occasionally look up and see the world; one must not be closed off.

  • Hard work pays off: Academic qualifications represent the past, abilities represent the present, and potential represents the future! If you don’t push yourself, you will never realize how excellent you are. Just strive to learn, explore your potential, and improve your technical skills; the future is no longer a dream! Let’s encourage each other!

  • Problem-solving approach: When encountering issues, always try to solve them yourself first. If you can’t, then seek help from others. This is a way to train yourself and respect others, and there are many ways to search:

    • Search on Baidu; often, you can find helpful information. Don’t overly emphasize Google while completely disregarding Baidu, as Chinese content is generally quicker to read;

    • First, search Google using Chinese keywords; then try English keywords;

    • Directly search on technical Q&A sites like Stack Overflow or Zhihu;

    • Refer to official documentation;

    • If you have source code, try reading it to see if you can find a solution;

  • Whenever possible, explore GitHub, read the official Google documentation, and stay engaged with the community; you will gain a lot;

  • Ultimately, the most crucial aspect is to be able to focus and persistently study technology.

About the Java and AndroidExpert Channel

The Java and Android Expert Channel is a public account with tens of thousands of followers discussing Java and Android development, sharing and creating the most valuable articles, enabling you to become an expert in this field!

We discuss the cutting-edge technologies of Android and Java development: Android performance optimization, pluginization, cross-platform, dynamic programming, strengthening and anti-cracking, etc., as well as design patterns/software architecture. This is a team composed of engineers from BAT companies.

Follow us for a red envelope, reply with “Baidu”, “Ali”, or “Tencent” for surprises!!! After following, you can join our WeChat group. The group consists of experts from Baidu, Alibaba, and Tencent.

We welcome you to follow us and discuss technology together. Scan or long-press the QR code below to follow us quickly. Or search for the public account: JANiubility.

How to Self-Learn Android Programming?

Public Account:JANiubility

How to Self-Learn Android Programming?

Leave a Comment