android-retrofit

Implement type-safe Retrofit networking with coroutines, OkHttp, and Hilt.

915|88|Updated Feb 6, 2024
One-click install
npx skills add https://github.com/new-silvermoon/awesome-android-agent-skills --skill android-retrofit-new-silvermoon
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: android-retrofit
Source: https://github.com/new-silvermoon/awesome-android-agent-skills/tree/main/.github/skills/android-retrofit
Command: npx skills add https://github.com/new-silvermoon/awesome-android-agent-skills --skill android-retrofit-new-silvermoon

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a structured approach to implementing a robust, type-safe HTTP networking layer for Android using Retrofit, reducing boilerplate and runtime errors.

Core Features & Use Cases

  • Type-safe API interfaces: Define service endpoints with Retrofit annotations to ensure compile-time correctness.
  • Coroutines-based calls: Expose suspend functions for seamless asynchronous programming.
  • OkHttp configuration: Centralized client with logging, timeouts, and retry policies.
  • DI integration: Hilt-based provisioning of Retrofit, OkHttp, and repositories for testability.
  • Error handling: Consistent error mapping and propagation in repositories.

Quick Start

Create a Retrofit service for a sample API, configure an OkHttp client with logging, and wire Retrofit with Hilt DI.

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 a type-safe Retrofit networking layer in Android?

To set up a type-safe Retrofit networking layer in Android, define service interfaces with Retrofit annotations, configure an OkHttp client with logging and timeouts, and wire dependencies using Hilt for compile-time correctness and testability.

How does Hilt dependency injection work with Retrofit and OkHttp?

Hilt dependency injection provisions Retrofit and OkHttp clients across modules, enabling centralized configuration and testable repository patterns without manually passing client instances through your Android app's class hierarchy.

What is the best way to handle Retrofit errors in Android coroutines?

The best way to handle Retrofit errors in Android coroutines is to expose suspend functions in your service interfaces and implement consistent error mapping and propagation logic directly within your repositories.

Can I configure OkHttp logging and retry policies for Retrofit services?

Yes, you can configure OkHttp logging and retry policies for Retrofit services by setting up a centralized OkHttp client with custom timeouts and interceptors before binding it to your Retrofit instance.

Why do I need coroutines suspend functions for Android API calls?

You need coroutines suspend functions for Android API calls to enable seamless asynchronous programming, ensuring type-safe Retrofit service definitions execute network requests without blocking the main thread.