Custom Annotations with Retrofit 2

In some cases it would be nice to have custom annotation support in retrofit2. A year ago I started to write a library in which I needed this feature. In this article I will explain how to achieve and implement this.

UPDATE: There’s an updated and more detailed version of this article using Kotlin:

Why do you need custom annotations?

I guess in most cases you don’t need to use custom annotations, but interceptors. Since retrofit2 is based on okhttp, you can use interceptors (in retrofit 1.X this…




Android Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to implement MongoDB using Spring Boot?

Tricks of the Trade Department: Coffee is for Closers — and Coders

Deploying Kubeflow 1.3 RC with Argo CD

Preparing a website for a traffic peak week 3: ECR, Makefile, CloudFront and JS bundling

Declaration of Homestead

Google Cloud Certified Associate Cloud Engineer

Migrating your Flutter project to null safety

Nusafety errors

Execute Command Remotely (No SSH) on Oracle Cloud Compute VM

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
André Tietz

André Tietz

Android Developer

More from Medium

Some Best Practices for Android App Architecture

View Binding in Android

View Binding in Android.

Android 13: Notification Runtime Permission