Skip to content
Back to skills

Android Networking

ASecurity

Use Kotlinx Serialization with Retrofit. It is type-safe, works with Kotlin `@Serializable` models, and is the serialization standard for this Android networking setup. Configure its converter explicitly with the JSON media type; do not rely on an unspecified or raw converter factory. Add the Kotlin serialization plugin and the JSON/converter dependencies using versions compatible with the project: ```kotlin plugins { kotlin("plugin.serialization") version "<kotlin-version>" } dependencies { ...

  • 584 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 5, 2026
developmentkotlinapi

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 12 files and shows the line behind each finding

Scanned September 5, 2026

npx -y skills add HoangNguyen0403/agent-skills-standard --skill android-networking --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Android Networking?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Android Networking
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hoangnguyen0403-android-networking-1c86b247/badge)](https://www.skillsdirectory.com/skills/hoangnguyen0403-android-networking-1c86b247)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
# JSON serialization for Retrofit

Use Kotlinx Serialization with Retrofit. It is type-safe, works with Kotlin `@Serializable` models, and is the serialization standard for this Android networking setup. Configure its converter explicitly with the JSON media type; do not rely on an unspecified or raw converter factory.

Add the Kotlin serialization plugin and the JSON/converter dependencies using versions compatible with the project:

```kotlin
plugins {
    kotlin("plugin.serialization") version "<kotlin-version>"
}

dependencies {
    implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:<version>")
    implementation("com.squareup.retrofit2:retrofit:<version>")
    implementation("com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:<version>")
}
```

Annotate DTOs with `@Serializable`. Use `@SerialName` whenever the JSON key differs from the Kotlin property name:

```kotlin
@Serializable
data class UserDto(
    @SerialName("user_id") val userId: String,
    @SerialName("display_name") val displayName: String,
)
```

Create one configured `Json` instance and pass it to Retrofit:

```kotlin
val json = Json {
    // Allows the server to add response fields without breaking old clients.
    ignoreUnknownKeys = true
}

val retrofit = Retrofit.Builder()
    .baseUrl(BuildConfig.API_URL) // must end with '/'
    .client(okHttpClient)
    .addConverterFactory(
        json.asConverterFactory("application/json".toMediaType())
    )
    .build()
```

The API interface remains a declaration-only boundary, for example:

```kotlin
interface UserApi {
    @GET("users/{id}")
    suspend fun getUser(@Path("id") id: String): UserDto
}
```

Keep status/error handling in the repository and return a `Result`-style wrapper there. Kotlinx Serialization controls JSON encoding/decoding; OkHttp still owns transport concerns such as authentication interceptors, logging, and certificate pinning.

Files in this skill

  • eval-1.baseline.md2.9 KB
  • eval-1.with-skill.md3.7 KB
  • eval-2.baseline.md2.4 KB
  • eval-2.with-skill.md1.9 KB
  • eval-3.baseline.md2.3 KB
  • eval-3.with-skill.md1.8 KB
  • trigger-1.md167 B
  • trigger-2.md146 B
  • trigger-3.md132 B
  • trigger-4.md156 B
  • trigger-5.md151 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.