
I clearly remember that day back in 2014, when I decided to start programming for Android. This turned out to be the best decision I took in my life. Almost two and a half years have already passed, and during this time I have the opportunity to learn something.
When I first started, I did not know anyone who could teach me, to show how to do it right. And I made a lot of mistakes, and I also spent a lot of time trying to fix them later.
')
A year and a half later, I had the chance to work with very talented and experienced Android developers who guided me and helped me put everything in order. These two ingredients taught me a lot. I realized that I had to DO, and most importantly, DO NOT.
And for some time I, as I can, try to help other developers, directly or indirectly. Here are my profiles:
StackOverflow and
Github .
In this article I will share some useful facts that I myself have come to over the years. They can help someone quickly get down to business and not repeat my mistakes.
Warning: in this article I will touch on Android, as well as ideas and results of programming, so if you are not familiar with one of these points, then you may not be interested in reading the article to the end. The rest, just read.
Publication support - the company EDISON , which implemented the recognition system for heavy vehicles and digital protocol maintenance , as well as developed a graphical user interface for the microtomograph .1. No need to reinvent the wheel
Initially, I decided not to use open source libraries. Whatever I need, I would like to do everything on my own. It was a very bad idea.
If you have any problem while improving your application, and if this problem has already been decided before you, then why not take advantage of it? So you can save a lot of time.
Better concentrate on the business logic of the application. If you want to make calls in the application, then for this you do not need to reinvent Retrofit.
Bonus: Android Arsenal contains almost all Android libraries ever created. Check it out.
2. Choose libraries correctly.
Many open source libraries are available on Github for free. But do not be very happy about it, and immediately begin to use them.
Check how many stars the library has, the more stars the better. See if the creator of the library has any other popular work. And check the discussions (open and closed), they can give you a better idea of ​​how stable and stable the library is in action.
If you have time, then you should check the code of this library and see if it is worth it.
You just make sure that the code you are going to use is reliable, error free and of high quality.
Hint: you can check any library directly from the command line using
Dryrun .

3. Make yourself a coffee, sit down and read the codes.
We spent more time reading other people's codes, not writing our own. If you don’t, then START today.
Any code that you can write today, you write only because you once read or learned it. This is a reflection of what you already know. You can improve your skills only if you study and read other people's work.
One of the most wonderful things about Android is that it’s a completely open platform. Open the code and see how they embodied it. Github has thousands of open source libraries. Just select one and see how the developer did it.
Bonus: Here is a list of the best libraries, and
here is a list of almost all open-source Android applications. Do not thank.
4. For God's sake, keep coding standards up to par.
If you compare writing code with writing, then coding standards are handwriting.
Just as you read codes created by others, other people will also read your code. But you do not want to scare them? And if you work together with other developers, then you definitely should pay attention to it.
Try to write short, understandable and readable codes that YOU and those who will read it could enjoy. Your code is as easy to read as any book.
The code is like poetry.
And do not complain if you write the code, and your colleagues will not talk with you for several days.
Bonus: And you should read
this and
that .
5. You need a ProGuard, but you definitely need it!
Never, never upload apps to the Play Store without using ProGuard. ProGuard will not only shorten your code, but it will also confuse the code, i.e. complicates the analysis, understanding of the algorithms of work in reverse engineering (reverse engineering).
It's free and comes bundled with the Android SDK. And there is no reason not to take advantage of this.
I saw several developers upload their apps to the Play Store without ProGuard. And not so skillful hackers took no more than a few hours to take advantage of the situation.
Hint: But if you need better protection, then you should not take advantage of ProGuard, but
DexGuard .
6. Use thoughtful architecture
Believe me, you will thank yourself for a long time if you first choose a normal architecture.
You can use MVP (Model-View-Presenter), it will divide the code into levels, thereby increasing the flexibility of the code and reduce maintenance time.
Here is a demo project to get you started. And if you have already suffered with this, but nothing happened with you, here is a detailed instruction for beginners.
Bonus: Read
this ,
this and pay attention to
this . This all can help you with MVP.

7. User interface as a joke. If you have to explain it, then this is a bad interface.
If you work for a company, and your position is a simple Android developer, then most likely you don’t need to worry about it, because the company probably has UI / UX designers who are responsible for the interface.
But if you work independently, then you need to remember to attend to this. I have already met developers who have created really good, functional applications, but the user interface (UI) looked awful, and the interaction experience (UX) hardly allowed to use the application.
Create a simple, clear and beautiful interface that will please the eye. You should think not just as a developer, but try to concentrate on the designer inside you.
Try to impress users with a beautiful user interface, so that they want to use your application again and even more (buy a premium version, for example).
It’s better to remove any design elements than to add extra ones. The design should be simple and minimalistic.
Bonus: You can always find inspiration by viewing the work of popular designers Dribble or
MaterialUp . There is also a
book you might want to read if you are interested.
8. Analytics - your best friend
If you want to create a really good application, then you need to use the analytics service, which allows you to find out the performance and application of certain parts of your application.
By analytics, I mean both error reports and visitor tracking, as you need this information.
Whatever you do, you will never be able to call the perfect application. When users start using your application on different devices with the Android operating system, and even different versions of Android, you will see that even the best codes will crash.
Error reports will help you track and correct them on time.
You should also start thinking as a marketer and analyze the use of certain functions of the application. This will help you to eliminate the difference between what kind of application you have created and how users want to see it.
Tip: Take advantage of
Firebase Crash Reporting and Analytics and thank you for it.
9. Become a marketing ninja
If you are an individual developer, then you need not only to “develop”, but also to understand marketing.
I saw how really good products were not popular just because of bad marketing, while mediocre was in demand.
If you are serious and want your applications to reach a wide audience, then you have to spend time and money on advertising. But before you start an advertising campaign, make sure that your application is already completely ready. You want every penny spent back, right?
Spend time exploring your competitors and how you can get around them. Determine who you have already bypassed, and who is just ahead.
Hint: here is an accessible website for market analysis. I like him
10. It’s time to optimize
This is exactly what most of us do not, but it is necessary.
There is a big difference between "writing code" and "writing optimized code."
Write code that works quickly and takes up less memory.
A non-optimized application works well, but only under normal circumstances, and in a difficult situation it can show what it really costs.
Check how much memory your application takes and if there is a memory leak.
Remember that even a small stream sinks a large ship. Spend time and deal with the Garbage Collector and heap dumps.
Hint: Use
Leak Canar to look for a memory leak. It can save you a lot of time.
11. Save 5 or more hours per week with Gradle
Most likely, you use Android Studio to improve applications, and Gradle as an automatic build system. Gradle is certainly good, but it is very slow. And it becomes even slower than a snail when the size of your application starts to increase.
I remember the endless hours I spent waiting for Gradle to complete the work. During busy days, it took me about an hour just waiting. And this is 5 hours a week.
But there is always the opportunity to accelerate.
You can follow
this advice , as well as
this , and speed up the build speed. Previously, it took me 4 minutes, and after optimization it takes me about 30 seconds.
12. Test, test, and test again!
Nothing is more important than testing. This is generally what should be first on the list.
Test your application as thoroughly as possible. Spend time writing test cases. Think of different stressful situations for the application and see if it can handle it.
Once I made a mistake - I released the application too quickly, not having time to test it properly. I thought that users would encounter a bunch of errors, send reports, and I will correct them.
Never, never do that. Yes, you can save a day, or two, or a week, but then you have to spend twice as much.
Never do anything in a hurry, everything has its time. Think long term. Time to sow and time to reap
13. Fragmentation in Android - The Devil Undercover

Fragmentation is one of the main problems of Android, and it seems that Google is not going to solve this problem, so you have to deal with it yourself.
Many devices work on Android, and they all have different screen sizes and specifications. An abundance of manufacturers who customize the operating system for the technical equipment of the device.
Add to this the various versions of Android, in which Google adds / removes the application programming interface (Application Programming Interface), which further increases the load (
here's a good example ).
For example, no Android developer has finished creating an application without using the SharedPreferences API. This is so common, although it did not fit the Samsung Galaxy S on Android 2.2 (
here’s an error report ).
Take the time to create different layouts for different screen sizes. Test on different devices with different versions of Android, etc.
Never think that the program will work, just because it seems so.
14. Start using Git!
If you are not yet using Git, then it's time to start.
When I first started programming for Android, unfortunately I didn’t know what Git was. I had to copy all versions of my program every day, and keep one copy on my hard drive, and another one in the “cloud”. Stupid right? Yes.
Git can improve your workflow. If someone asks me to name the program that I use every day, and which I couldn’t stop using, it will definitely be Git.
And, perhaps, after several days of use, you just fall in love with this program and want to find out how Git works, it will help
you .
And when you start a big project, and get confused about how it is worth supporting the branching model, it will help
you .
Bonus: if you have just started, and you still can’t afford the monthly fee for personal storage on
GitHub , then you should use
BitBucket - it’s completely free.
15. Make life difficult for hackers.
The fact that Android is an open system makes it vulnerable to attacks. Even Android applications can undergo decompilation, reverse engineering (reverse engineering), cracking and manipulation.
You do not want this to happen with your application?
Then you should know how to protect the application with the key API. If you are dealing with sensitive data, then you need to know how to encrypt it, which algorithm to choose (secure, not fast).
You must also store encryption keys either on the server or on a local disk (if necessary). Also, you should protect the application from copying using ADB (Android Debug Bridge). If you are storing sensitive data in a database, be sure to mess up the code.
And what if the premium version of your application is hacked and exposed for free? You will incur losses.
There are several things you can do to prevent falsifying your application. Of course, there is no 100% protection. Any experienced hacker with the necessary information, applications, and the presence of desire will be able to hack your application.
All you can do is complicate the task. Protect the application so that the hacker doesn't just hack it.
Bonus: Read
this and
this article. This will make a good start.
16. Develop programs on a budget device
I, like everyone, like to use expensive smartphones. But such a device should be used only for personal purposes, and not for the development of the program.
Leading models of devices will hide many flaws. Suppose you are doing something related to the user interface (UI) that will lead to errors in the interface, but on a powerful device you may not even notice.
An old budget smartphone with a bunch of installed applications is the best option.

17. Invest in learning Design Patterns
Such an investment will pay off constantly.
During the creation of a complex program, you will encounter several standard problems that have already been solved by more competent people. Problem solving - design patterns.
Start spending some time today to learn Java Design Patterns.
Here is a Github
project that demonstrates all the design patterns known to humanity.
It is best to start with the study of such important ones as Singleton, Adapter, Factory Method, Iterator, Dependency Injection, Builder, Strategy.
It seems that there are too many of them? Not really. You will definitely like them.
Hint: read books like Joshua Bloch “
Java. Effective programming ”and Martin Fowler“
Refactoring . ”
18. Time to give
We were all helped by the people around us. Let's admit it.

If you have a problem, the first thing you do is look for the answer on Google and on StackOverflow. Sometimes, when you don’t have time, you simply copy and paste a ready-made solution from an answer that has scored more likes.
Even the free libraries from Github that you use, as they save you time and effort. And all because someone once spent their time to create it, and then laid out on the Internet to make the world a little better.
Remember the day when you could not understand a difficult idea or something completely new to you, and, suddenly, you found a wonderful blog, thanks to which you could understand. And all because someone probably did not go on a date and wrote this article.
And now it's time to pay back. The more you share, the more you will get in return.
We are all busy with our own work, and it is so difficult for us to manage time and do something for others. But you can try to find some time and make this Android community better.
I tried to share some things that I realized during this short journey with Android. But I will continue this way, find out more, and I will have something to share. I hope that this will help someone, and simplify life.