The original link
There are two kinds of people who do everything, those who work hard and those who follow the advice of others. Here are some lessons I learned that I hope will help you:
- Think twice before importing any third party packages, because this is a big responsibility.
- Do not draw where the user cannot see.
- Think twice about whether the use of a database is necessary to the business.
65535
Problems are coming up very quickly,hereIt can help you out.- alternativeAsynchronous tasksThe best thing is
RxJava
There is no one. - Retrofit is the best web request framework out there.
- You can use Retrolambda to simplify your code.
- RxJava+Retrofit+Retrolambda couldn’t be more fun to use in combination.
- EventBusIt’s a great message bus library, and I use it, too, but I don’t rely too much on __, because using it too much can cause your code __ to be difficult to understand and your logic to be messy
RxBus
. - Subcontracting is divided by functional characteristics, not by business layer.
- Do not do time-consuming operations on the main thread.
- Using Lint can help you optimize layouts and layout levels, eliminating unnecessary layout or controls.
- If you use
Gradle
Then go as far as you canSpeed up compilation. - Enable the compile report to see the time statistics during the compile process.
- Be as generic as possible in your architecture.
- Testing is time-consuming, but you’ll solve bugs faster and your code more robust than if you didn’t test at all.
- Using dependency injection makes your app more modular and easier to test.
- Subscribing to this site will help you a lot.
- Never use a personal email account for the app store platform, including some third-party service providers.
- In the use of
EditText
When usingThe appropriateInput type. - use
Android Studio -> Analyze
To analyze and locate bugs. - Keep an eye on newer technologies and libraries. The DryRun library, for example, can help reduce the time you spend building remote warehouse projects. PS: I use it myself. It couldn’t be better.
Service
Do what it should do, and destroy it as soon as it needs to be destroyed.- Use AccountManager to advise on things like user names and email addresses.
- use
CI (Continuous Integration)
To build and describe your own beta and official APK. - Don’t run your own
CI
Servers. Maintaining servers is time-consuming because there will beDisk space/security issues/Updating the server to prevent SSL attacks
All kinds of shiba questions waiting for you. usecircleci
.travis
orshippable
They are cheap and let you worry less. - You can use automatic deployment when you publish your app.
- If you need to import a library that is very large and you only need a fraction of its functionality, you should find a smaller library that is more suitable for you (ProGuard compresses resources).
- Don’t rely on too many imports
modules
Unless you really need to. Because too muchmodules
Can result in a slower build (CI is an example) than using binary directly.jar/.aar
It’s about four times slower to speak. - Consider putting
.PNG
replace.SVG
. - Abstract classes in the Library make it easy to control and replace usage scenarios (e.g.
AppLogger. D (" message ")
It includesLog.d(TAG, message)
And it can be optimized toTimber.d(message)
). - Monitor network connections and the types of connections you will find ->
wifi
Data may be refreshed more frequently under a connection. - Monitor your charge and battery and you’ll notice that -> data updates may be more frequent when charging and slower when low.
- The USER interface is a joke, and unless you can explain it, it’s not good enough.
- Testing is well suited for performance tuning: write a few implementations slowly (but correctly) and then verify the optimization without breaking the test.