android-retrofit

Configures Retrofit networking in Android with coroutines, OkHttp, Hilt, and repository error handling.

Updated Jul 1, 2026
One-click install
npx skills add https://github.com/w0lzard/Wolzard-s-Marketplace --skill android-retrofit-w0lzard
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: android-retrofit
Source: https://github.com/w0lzard/Wolzard-s-Marketplace/tree/main/plugins/personal-skills/skills/android-retrofit
Command: npx skills add https://github.com/w0lzard/Wolzard-s-Marketplace --skill android-retrofit-w0lzard

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Setting up Retrofit correctly in an Android app involves many decisions — suspend functions vs Response wrappers, OkHttp configuration, Hilt module wiring, and where to handle network exceptions. This Skill provides proven patterns so you avoid common mistakes like leaking HttpException into ViewModels or duplicating auth headers on every endpoint. ## Core Features & Use Cases - Service Interface Patterns: Declare suspend endpoints with @Path, @Query, @Body, @FormUrlEncoded, @Multipart, and header annotations, with guidance on when to use Response<T> versus direct return types. - Hilt & OkHttp Setup: Complete NetworkModule with kotlinx.serialization converter, debug-gated logging interceptor, and sensible timeouts. - Repository Error Handling: Maps HttpException and IOException to a unified DataError sealed class so ViewModels never depend on network internals. - Use Case: When adding a new API to your Android app, use this Skill to scaffold the service interface, Hilt module, auth interceptor, and repository layer following consistent architecture. ## Quick Start Set up a Retrofit service interface with Hilt and repository error handling for the GitHub API in my Android project.

Frequently Asked Questions about android-retrofit

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up Retrofit with coroutines in Android?

Declare all service endpoints as suspend functions returning the body type directly, then build Retrofit with an OkHttpClient and a kotlinx.serialization converter factory. Retrofit automatically throws HttpException on non-2xx responses, which you catch in the repository layer.

When should I use Response<T> vs direct return type in Retrofit?

Use the direct body type when only 2xx success matters — Retrofit throws HttpException otherwise, giving clean try/catch handling. Use Response<T> only when you need status codes, headers, or the error body content such as validation messages.

How do I add an auth token to Retrofit requests?

Use an OkHttp Interceptor that reads the token from a TokenProvider and adds the Authorization header to every request. This avoids repeating @Header("Authorization") parameters on each endpoint, which is error-prone and easy to forget.

Should ViewModels catch HttpException directly?

No. The repository should catch HttpException and IOException and map them to domain error types like a DataError sealed class. This keeps the ViewModel independent of Retrofit so swapping networking libraries does not require UI changes.

How do I configure Retrofit with Hilt dependency injection?

Create a @Module installed in SingletonComponent that provides Json, OkHttpClient with debug-gated logging and timeouts, Retrofit with the serialization converter, and each service interface via retrofit.create(). Mark providers @Singleton to share instances.