Create Android slim bindings for MAUI/.NET Android. USE FOR: slim Android binding, Kotlin/Java wrappers, build.gradle.kts, Maven, AAR/JAR, AndroidMavenLibrary, AndroidLibrary, @JvmStatic, XA4241/XA4242, Xamarin.AndroidX/Kotlin NuGets. DO NOT USE FOR: iOS/macOS bindings, general MAUI apps, or NuGet packaging.
Create Android slim bindings for MAUI/.NET Android. USE FOR: slim Android binding, Kotlin/Java wrappers, build.gradle.kts, Maven, AAR/JAR, AndroidMavenLibrary, AndroidLibrary, @JvmStatic, XA4241/XA4242, Xamarin.AndroidX/Kotlin NuGets. DO NOT USE FOR: iOS/macOS bindings, general MAUI apps, or NuGet packaging.
When to use this skill
Activate this skill when the user asks:
How do I create Android bindings for a native library?
How do I wrap an Android SDK for use in .NET MAUI?
How do I create slim bindings for Android?
How do I use Native Library Interop for Android?
How do I bind a Kotlin library to .NET?
How do I bind a Java library to .NET?
How do I integrate an AAR or JAR into .NET MAUI?
How do I create a Java/Kotlin wrapper for a native Android library?
How do I update Android bindings when the native SDK changes?
How do I fix Android binding build errors?
How do I expose native Android APIs to C#?
How do I resolve Maven dependencies for Android bindings?
How do I handle AndroidX dependencies in bindings?
How do I fix "Java dependency is not satisfied" errors?
How do I use AndroidMavenLibrary in my binding project?
Overview
This skill guides the creation of Native Library Interop (Slim Bindings) for Android. This modern approach creates a thin native Java/Kotlin wrapper exposing only the APIs you need from a native Android library, making bindings easier to create and maintain.
When to Use Slim Bindings vs Traditional Bindings
Scenario
Recommended Approach
Need only a subset of library functionality
Slim Bindings
Easier maintenance when SDK updates
Slim Bindings
Prefer working in Java/Kotlin for wrapper
Slim Bindings
Better isolation from breaking changes
Slim Bindings
Complex libraries with many dependencies
Slim Bindings
Need entire library API surface
Traditional Bindings
Creating bindings for third-party developers
Traditional Bindings
Already maintaining traditional bindings
Traditional Bindings
Inputs
Parameter
Required
Example
Notes
libraryName
yes
FirebaseMessaging, OkHttp
Name of the native Android library to bind
bindingProjectName
yes
MyBinding.Android
Name for the C# binding project
dependencySource
no
maven, aar, jar
How the native library is distributed
targetFrameworks
no
net10.0-android
Target frameworks (default: latest .NET Android)
exposedApis
no
List of specific APIs
Which native APIs to expose (helps scope the wrapper)
mavenCoordinates
no
com.example:library:1.0.0
Maven coordinates if library is from Maven repository
Before creating any bindings, analyze the complete dependency tree of your target library. This is the most critical step and where most binding projects fail.
Prerequisites: JDK 17+, Android SDK with ANDROID_HOME set, .NET SDK 9+. You don't need Gradle installed globally; the Gradle Wrapper downloads the correct version automatically.
Step 2: Create the Android Library Project
Choose one of these approaches:
Option A: Android Studio (recommended for GUI-based projects: create a "No Activity" project, then add an Android Library module)
Option B: gradle init with Wrapper (recommended for CLI-based projects: scaffold with Gradle using the Wrapper, then convert to an Android library)
Option C: CommunityToolkit NativeLibraryInterop template (clone and use the CommunityToolkit NativeLibraryInterop template as your starting point)
Option D: Manual creation with Gradle Wrapper (create the project structure manually using the Gradle Wrapper)
After project creation, configure settings.gradle.kts, root build.gradle.kts, and app/build.gradle.kts with your library dependency.
dotnet new androidbinding -n MyBinding.Android.Binding
Key .csproj elements:
<AndroidLibrary> — reference the built AAR
<PackageReference> — NuGet packages for transitive dependencies
<AndroidMavenLibrary Bind="false"> — Maven deps without a NuGet equivalent
<AndroidIgnoredJavaDependency> — compile-time only dependencies
Configure Transforms/Metadata.xml for namespace renaming and parameter names.
Step 7: Resolve Dependencies
Build and resolve XA4241/XA4242 errors using this decision tree:
For each unsatisfied dependency:
Is there a XA4242 suggestion?
Install the suggested NuGet package
Is the dependency needed from C#?
Find/create a binding NuGet or create your own binding
Use AndroidMavenLibrary with Bind="false"
Is it a compile-time only dependency (annotations, processors)?
Use AndroidIgnoredJavaDependency
Create a separate binding project or include AAR/JAR directly
Edit Transforms/Metadata.xml to rename packages, classes, parameters, and remove internal types. Examine obj/Debug/net10.0-android/api.xml after building to construct correct XPath expressions.
Step 9: Build and Verify
dotnet build -c Release
Step 10: Use in Your MAUI App
Add a conditional <ProjectReference>, initialize in MauiProgram.cs using ConfigureLifecycleEvents, and implement callback interfaces by extending Java.Lang.Object.
Updating Bindings When Native SDK Changes
Update native dependency version in app/build.gradle.kts
Re-analyze dependencies with ./gradlew app:dependencies
Update the Java/Kotlin wrapper if APIs changed
Rebuild the AAR with ./gradlew :app:assembleRelease
Update NuGet packages and Maven dependencies in binding .csproj
Rebuild C# binding and fix any new XA4241/XA4242 errors