Building Android(安卓)Apps 30条建议
16lz
2021-01-26
Building Android Apps — 30 things that experience made me learn the hard way
There are two kinds of people — those who learn the hard way and those who learn by taking someone’s advice. Here are some of the things I’ve learned along the way that I want to share with you:
- Think twice before adding any third party library, it’s areallyseriouscommitment;
- If the user can’t see it,don’t draw it!;
- Don’t use a database unless youreallyneed to;
- Hitting the 65k method count mark is gonna happen fast, I mean really fast! Andmultidexingcan save you;
- RxJavais thebestalternative toAsyncTasks and so much more;
- Retrofitis thebestnetworkinglibrarythere is;
- Shorten your code withRetrolambda;
- CombineRxJava with Retrofit and Retrolambdafor maximum awesomeness!;
- I useEventBusand it’s great, but Idon’tuse it too much because the codebase would get really messy;
- Package by Feature, not layers;
- Moveeverythingoff the application thread;
- lintyour views to help you optimize the layouts and layout hierarchies so you can identify redundant views that could perhaps be removed;
- If you’re usinggradle, speed it up anyway youcan;
- Doprofile reportsof your builds to see what is taking the build time;
- Use awell knownarchitecture;
- Testing takes time but it’s faster and more robust than coding without tests once you’ve got the hang of it;
- Usedependency injectionto make your app more modular and therefore easier to test;
- Listening tofragmented podcastwill be great for you;
- Neveruse your personal email for your android market publisher account;
- Alwaysuseappropriateinput types;
- Useanalyticsto find usage patterns and isolate bugs;
- Stay on top of newlibraries(usedryrunto test them out faster);
- Your services should do what they need to do anddieas quickly as possible;
- Use theAccount Managerto suggest login usernames and email addresses;
- UseCI(Continuous Integration) to build and distribute your beta and production.apk’s;
- Don’t run your ownCIserver, maintaining the server is time consuming because of disk space/security issues/updating the server to protect from SSL attacks, etc. Use circleci, travis or shippable, they’re cheap and it’s one less thing to worry about;
- Automate your deployments to the playstore;
- If a library is massive and you are only using a small subset of its functions you should find an alternativesmalleroption (rely onproguardfor instance);
- Don’t use more modules than you actually need. Ifthatmodules are not constantly modified, it’s important to have into consideration that the time needed to compile them from scratch (CIbuilds are a good example), or even to check if the previous individual module build is up-to-date, can be up to almost 4x greater than to simply load that dependency as a binary.jar/.aar.
- Startthinking about ditching PNGs for SVGs;
- Make library abstraction classes, it’ll be way easier to switch to a new library if you only need to switch in one place (e.g.AppLogger.d(“message”)can containLog.d(TAG, message)and later realise thatTimber.d(message)is a better option);
- Monitor connectivity and type of connection (moredataupdateswhile onwifi?);
- Monitor power source and battery (more data updateswhilecharging?Suspend updateswhenbattery is low?);
- A user interface is like a joke. If you have to explain it, it’s not that good;
- Tests are great for performance: Write slow (but correct) implementation then verify optimizations don’t break anything with tests.
If you have any questions drop me a tweet @cesarmcferreira!
form:https://medium.com/@cesarmcferreira/building-android-apps-30-things-that-experience-made-me-learn-the-hard-way-313680430bf9#.iz9oy4ekc
更多相关文章
- 代码中设置drawableleft
- android 3.0 隐藏 系统标题栏
- Android开发中activity切换动画的实现
- Android(安卓)学习 笔记_05. 文件下载
- Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
- 技术博客汇总
- android 2.3 wifi (一)
- AndRoid Notification的清空和修改
- Android中的Chronometer