preface

The following advice is based on my own experience and several blogs on the web

  1. Control the size of each image, as they will affect the size of the APK (and interact with the UI). Here are some sites that compress images.

    Known as panda compression

    Smartmap is a platform for image compression and image format conversion developed by Tencent ISUX front-end team. Its functions include PNG, JPEG, GIF and other formats of image compression, as well as automatic selection of the best image format for uploading pictures. At the same time, the platform will also convert a webP format image for the user

    ImageAlpha significantly reduces the file size (including alpha transparency) of 24-bit PNG files by applying lossy compression and conversion to the more efficient PNG8 + alpha format

    Imageoptim lossless compression and client support (Mac client)

    SquooshGoogle is an open source online service for compressing images. In addition to reducing size, it can also do simple editing, including cropping and reducing color palettes

  2. If a large amount of data needs to be passed between page jumps, it is not recommended to use intents or bundles, but rather RxBus, EventBus, and LiveDataBus. LiveDataBus is highly recommended. But don’t abuse it

  3. Adopt PBF (Package By Feature) to refer to Blankj’s Android development specification

  4. ConstraintLayout, Include, ViewStub, Merge, and avoid nesting.

  5. Choose open source libraries carefully; Don’t import a large library just for a small function

  6. Use auxiliary tools to detect memory leaks, performance checks, exception reporting systems, and so on. Recommend some wheels (lots of tools, choose your own)

    Bugly Tencent Bugly provides mobile developers with professional abnormal reporting and operation statistics, helping developers quickly find and solve anomalies, grasping product operation dynamics, and timely following up user feedback

    BlockCanary is a non-invasive performance monitoring component for Android

    LeakCanary Memory leak detection library

  7. Use dependency injection decoupling!! Decouple!! Decouple!! Dagger2 on Android

  8. Don’t write useless code to your Application, keep it simple, or it will slow down your Application’s initialization and startup

  9. Avoid using databases unless you really need to

  10. Use DialogFragment instead of Dialog, official explanation

  11. Don’t use enumerations too much; they take up more memory than integers

  12. Use some Android-specific data structures, such as SparseArray and Pair, for better performance

  13. Use soft and weak references appropriately, official explanation

  14. Use thread pools instead of creating a large number of threads; Reference: Android threads and thread pools is enough

  15. Add comments appropriately!! Add comments appropriately!! Add comments appropriately!!

  16. Don’t create objects or do time-consuming tasks inside View’s onDraw method

  17. Don’t set objects like Context or View to static

  18. Use static inner classes whenever possible to avoid potential memory leaks due to inner classes

  19. A good set of development practices; Reference: Android development specification

  20. Code should have a sense of hierarchy and follow a single responsibility, see: Six principles of design Pattern (1) : Single responsibility principle

That’s all I can think of at present, I’ll update it later