2019年11月22日 本文已过时 请查看Android官方的Dependency Injection教程和Codelab 谁能想到dagger-android要凉凉了呢?

2018年5月20日更新了测试的更多思路

2018年5月19日更新了Dagger2测试的思路

现在是2018年5月,Dagger2的版本是2.16,Kotlin版本是1.2,IDE是Android Studio

过时的话就要话就要慎重地看。

Dagger2学起来是真心难受,现有的很多资料都已过世,误人子弟,而且和Kotlin结合在一起,会有很多很多坑和弯路。

Copy-pasting code makes it hard to refactor later on. As more and more developers copy-paste that block, fewer will know what it actually does.

本路线图指明的是:

从:对Dagger2只懂一点,不熟悉,只会到处复制粘贴。

到:熟悉Dagger2的使用方法,明白什么时候用interface,什么时候用abstract class,什么时候用@JvmStatic等等,能够看懂生成的代码,能分辨出Dagger2实现的好坏。

阅读全文 »

2018年5月18日更新:Moshi 1.6增加了Codegen的选项,可以取代Kotshi。原方案依旧可行。

之前用Gson序列化Kotlin的data class一直都没问题,但一天当data class中出现了默认参数时,问题就来了。

如果JSON中没有对应的Field,按道理Gson应该生成一个使用了默认参数的data class,但它没有,而且会无视Kotlin的不可null,直接生成一个null。

那换一个支持Kotlin的JSON库呗。这时Moshi就很厉害了,自带一个Kotlin的Adapter,用起来很舒服。但是在最后生成Release版本时,才发现安装包大了600+KB。原因是Moshi对Kotlin的支持使用了Kotlin的Reflection,这个就很占空间,虽然也有Kotlin Relection Lite这个轻量级版本,但目前并不支持。

所以,我在

阅读全文 »

之前不知在哪里看到Android开发者都应该了解一下Android Internal,就截了图记了下来。现在有时间了,就找了一些Android Internal的内容,记了些笔记。相应的资料也列在了各个章节末尾。

不是很全,不保证全对,不保证维护

基于Linux内核的Android

Android之所以享誉盛名,是因为在Linux内核基础上已改的面目全非。。就是为了适应手机那小内存、差CPU、续航是问题等的特点。Android不是一个Linux的发行版。

阅读全文 »

之前需要用代码来代替一些繁琐重复的网页操作,自然想到用Python自动化这些工作。

然后找到了这篇文章。它用了Splinter,一个Selenium的包装。尝试之后发现意外地简单。

内容大同小异,说明几个坑。

阅读全文 »

虽然最终选择了GithubPages + Hexo,但之前使用Docker搭的Wordpress + HTTPS。搭完后才发现维护起来又累又贵,就把整个流程贴出来留给有缘人吧。

甩锅申明:出了问题我不知道怎么解决,请问万能的Stackoverflow吧😉

好处:

  1. 方便,命令几乎都是cd, ls和nano/vim。
  2. 快速,不需要LAMP或者LNMP漫长的安装/编译过程。新机器建站和删库跑路都很快。
  3. 干净,不污染其他文件夹,删除网站只需要一条Docker命令。
  4. https,Let’s Encrypt! 不仅是网站,还要加个绿色的小锁。
阅读全文 »

Updated: 2025.8.1

Android

In case you want to learn about Android Development

Advice

Framework

AnDevCon: Android Internals Overview - Marko Gargenta.mov

RecyclerView

Drag and Swipe with RecyclerView

Enter animation and LayoutAnimation

RecyclerView — More Animations with Less Code using Support Library ListAdapter

SortedList

DiffUtil

SnapHelper

Multiple item types

Improving scrolling behavior of nested RecyclerViews - Part 1

Saving scroll state of nested RecyclerViews - Part 2

Optimizing Nested RecyclerView

Fixing RecyclerView nested scrolling in opposite direction

Paging Image Carousel with RecyclerView

Drag and Drop between two RecyclerView ‘s

Animation

Get Animated (Android Dev Summit ‘18)

Exploring Meaningful Motion on Android

Synchronously Animating Toolbar, TabLayout, FloatingActionButton and StatusBar Background Colors on Android

An Introduction to Icon Animation Techniques

Make a moving Gradient Background in Android

Beautiful animations using Android ConstraintLayout

Make your app shine #3: How to reveal an activity with circular revelation

Polishing UI: Android StateListAnimator

StateListAnimator — a Powerful Little Tool for Elevation Animation

Scroll your Bottom Navigation View away with 10 lines of code

TransitionDrawable — Small Gems of the Android Framework

Animating your keyboard (part 1)

Animating your keyboard (part 2): reacting to WindowInset animations

One still surprisingly valid reason to use the old Animation (API 1+)

Playing with Material Design Transitions ✨ - How to make material design transitions between two screens?

AnimatedIcons: Strikethru

Design and Style

Best Practices for Themes and Styles (Android Dev Summit ‘18)

Good to great UI animation tips

Spantastic text styling with Spans

Using gradient for styling text

Styling internationalized text in Android

Mastering Android Themes

Understanding how to declaratively style text on Android

AppCompat — Age of the vectors

Night Theme => AppCompat — DayNight

Vector illustration basics for Android developers - Part 1: Primitive Shapes

Material shadows on Android by Sebastiano Poggi, JetBrains EN

Android Styling: Common Theme Attributes

Motional Intelligence: Build smarter animations

Writing

Gesture Navigation: going edge-to-edge

Animating your keyboard using WindowInsets

Note 1: Hex color codes are not currently supported for android:colorBackground, hence why a color resource was used.

Custom View

Official Documentation

Mastering the Android Touch System

How to make a swipe button

Creating an Extendable Floating Action Button in Android

How I drew custom shapes in bottom bar

How we implemented 3D cards in Revolut

Creating Custom Views in Android

Android: Why your Canvas shapes aren’t smooth

Jetpack Compose

Missing Classes and Functions in Jetpack Compose Compiler Reports, and How to Fix

Gestures in Jetpack Compose

Gestures in Jetpack compose — All you need to know

The Do’s and Don’ts of Jetpack Compose

Scoped recomposition in Jetpack Compose — what happens when state changes?

Parallax Effect with SensorManager using Jetpack Compose

Ticker Board in Jetpack Compose

Neumorphism in Jetpack Compose

Background Execution

Modern background execution in Android

Things to consider before running background tasks

Android Handler Internals

Exploring Android Processes

Exploring Android Thread Priority

Executor Framework- Understanding the basics

Understanding CPU and I/O bound for asynchronous operations

miui10 no kill list

Android-App-Chain-Wakeup

Access the clipboard from the background

Background Work on Chinese ROMs

Why your Push Notifications never see the light of day

Google’s reply to WorkManager on Chinese ROMs. Only applys to ForegroundService and other

Android Studio

50 Android Studio Tips, Tricks & Resources you should be familiar with, as an Android Developer

Android Studio Debugger

Deep dive into .idea folder in Android Studio

Gradle

Using Gradle build cache with Kotlin

Gradle Tips and Tricks for Android(includes kotlin-dsl, resolving dependencies conflicts, apk splits, buildConfigField, externalNativeBuild, buildTypes configuration, gradle properties, offline mode, product flavors, dependency graph)

How to Include an External .aar File Using Gradle?

How to manage dependencies in a multi module project?

Name your .apk & .aab files, archivesBaseName in build.gradle of app module

Android library development - Getting started

Unbreaking the changes in Compose 1.7

Mitigating soft verification issues in R8 and D8

Build Time

Build your Android app Faster and Smaller than ever

How I reduced my Android build times by 89%

Faster Android Build Times

ADB

ADB Commands — Part III

Practical ADB usage to enhance your life! - Benjamin Kadel

Dagger2(Always read the newets posts)

Official Doc

Dagger 2 Generated Code.

Understanding Dagger 2 Multibindings + ViewModel

Injection into Android Component’s Constructors is real

Kotlin+Dagger best practices/documentation

Brave New Android World with AssistedInject

APK

Playing APK Golf - Reducing an Android APK’s size by 99.99%

Reducing APK size by using ABI Filters and APK split

android-keystore-password-recover

Proguard Hell

Troubleshooting ProGuard issues on Android

Reading ProGuard’s Outputs

Feeding ProGuard’s inputs: where are all of these rules coming from?

How Proguard Works

Practical ProGuard rules examples

Android’s Built-in ProGuard Rules: The Missing Guide

Strings, Please! Eliminating Data Leaks Caused by Kotlin Assertions

Security

Hybrid Encryption in Android: Secure Communication Between Mobile and Backend Systems

Android Undercover: Native Code Translation for AV Stealth - DC615/DEF CON Nashville

How long will you go to protect your Android app from being tampered?

Securing Network Data Tutorial for Android

Bang! Bang! You have been hacked.

Performing OAuth on Android with Custom Tabs

Securing API Keys using Android NDK (Native Development Kit)

Android Unique Device ID: History and Updates

Licenses

How open source licenses work and how to add them to your projects

How to Choose Licnese

Including Open Source Notices (Including an activity showing all libraries licenses. However, This official library doesn’t work very well)

OSS

Things I wish I knew when I started building Android SDK/Libraries

The beginner’s guide to contributing to a GitHub project

Removing sensitive data from a repository

Publish Your Android Library on JitPack for Better Reachability

What legal documents should your app have?

Release

Did you get one of these Google Play Developer Policy Violation Emails?

Clean your status bar like a pro!

Demo mode doc

Enhance Your Google Play Store Description With Rich Formatting & Emojis

Best Languages for App Localization

Signing Android Apps

Test

Understanding and Mastering the World of Android Testing (Part 1)

Mocking Kotlin classes with Mockito — the fast way

Testing App Startup Performance

Architecture

Yes, That’s MVI: The Pattern’s Full History, Misconceptions, and Modern Android Form

Android One-off Events: Approaches, evolution & anti-patterns

Google I/O 2018 app — Architecture and Testing

A Guided Tour inside a clean architecture code base.

Building a Shazam Clone Part 1 (Design) — Building Android Apps Series

Kotlin Clean Architecture

Modularization - Lessons learned

MVWTF: Demystifying Architecture Patterns

Performance

Performance Improvements for Search on The Yelp Android App

Advanced JSON parsing techniques using Moshi and Kotlin

How to use responsive images to speed up your apps — with android glide example

Resources for Learning OpenGL  -  An Android Developers Guide

How OkCredit Android App boosted Network Performance by 30%

Don’t Prewarm App Features

CI, Continuous Integration

Using GitHub Actions for Android Continuous Integration and Delivery

Cloud Continuous Integration on Android with Kotlin Project

Android GitHub Actions Setup

How to publish a Kotlin Multiplatform Android app on Play Store with GitHub Actions

Archiecture Components

5 common mistakes when using Architecture Components

Android ViewModel. How it works.

Room

7 Pro-tips for Room

Understanding migrations with Room

Room 🔗 RxJava

Firebase

Use Firebase without Google Services Gradle Plugin

Java

Modern DateTimes on Android

Kotlin

Kotlin Sequences: An Illustrated Guide

An Illustrated Guide to Covariance and Contravariance in Kotlin

The Ins and Outs of Generic Variance in Kotlin

Coroutines

Seven recipes to understand flows and asynchrony in Kotlin

How I Fell in Kotlin’s RunBlocking Deadlock Trap, and How You Can Avoid It

KotlinConf 2017 - Deep Dive into Coroutines on JVM by Roman Elizarov

KotlinConf 2017 - Deep Dive into Coroutines on JVM by Roman Elizarov

Kotlin Coroutines patterns & anti-patterns

Easy Coroutines in Android: viewModelScope

KotlinConf 2019: Coroutines! Gotta catch ‘em all! by Florina Muntenescu & Manuel Vivo

Create an application CoroutineScope using Hilt

The Silent Killer That’s Crashing Your Coroutines

Framework Classes

Application

Reminder: “allowBackup=true” is the devil if you are using Hilt or Dagger

This is why your subclassed Application isn’t always instantiated

You basically need to duplicate it into your app’s manifest with the same name and add the exported=”true/false” as the only tag.

Fixed support for Configuration override use cases, including custom locales and font scales. See here for an example of how to correctly implement overrides using appcompat:1.2.0.

Context

Mastering Android context

Enumerating Resources in Android

Activity

Android “launchMode” (Visualized)

The Android Launch Mode Animated CheatSheet

Finally understanding how references work in Android and Java

The (Complete) Android Splash Screen Guide

The Android Lifecycle cheat sheet — part I: Single Activities

The Journey Of Launching An Android Activity

Seamless Android app launch animations using Intent Source Bounds

Fragment Transactions & Activity State Loss

Storage

DevBytes: Android 4.4 Storage Access Framework: Client

When you access an existing media file, you can use the value of the DATA column in your logic.

Views

Android ImageView ScaleType: A Visual Guide

Scrolling Behavior for Appbars in Android

AppCompat View Inflation

Clean Android WebView caching

Media

Audio Focus

Discover the core Android API for Speech Recognition.

PIP

Making magic moments with picture in picture (Three more links at the end of the article)

Vibrate

The Correct Way to Vibrate

Google Play In-App Purchase

Exploring the Play Billing Library for Android

Interviews

Android Interview Series 2024

A Simple Framework For Mobile System Design Interviews

Programming

Best of Fluent 2012: /Reg(exp){2}lained/: Demystifying Regular Expressions

A Programmer’s Introduction to Unicode

Leetcode Pattern 1 BFS + DFS == 25% of the problems — part 1

Understanding SOLID Principles: Open Closed Principle

Demystifying Dynamic Programming

My favorite examples of functional programming in Kotlin(powerset in the middle of the article)

Flutter

Deep Dive Into The Pubspec.yaml File

What’s the pubspec.lock file in a Flutter Project?(Some files are misplaced)

Other

Generic

Why not GUI application terminate like console application?

Why is Python so slow?

Server

Capture all passwords trying to ssh into my server!

Create your first safe server that’s ready for production

Configure SSH Keys Authentication With PuTTY And Linux Server In 5 Quick Steps

Disable a user’s login without disabling the account

A fast and easy Docker tutorial for beginners (video series)

Getting Started with Docker on Your VPS

Hexo

Use Hexo and deploy to GitHub Pages

Using Git Submodules to Manage Your Custom Hexo Theme

Encryption

PGP Guide

Game

From Zero to Game Designer: how to start building video games even if you don’t have any experience

magictools

Thoughts

Optimize Your Programming Decisions for the 95%, Not the 5%

😍