$npx -y skills add Redth/maui-skillz --skill android-slim-bindingsCreate and update slim/native platform interop bindings for Android in .NET MAUI and .NET for Android projects. Guides through creating Java/Kotlin wrappers, configuring Gradle projects, resolving Maven dependencies, generating C# bindings, and integrating native Android librarie
| 1 | # When to use this skill |
| 2 | |
| 3 | Activate this skill when the user asks: |
| 4 | - How do I create Android bindings for a native library? |
| 5 | - How do I wrap an Android SDK for use in .NET MAUI? |
| 6 | - How do I create slim bindings for Android? |
| 7 | - How do I use Native Library Interop for Android? |
| 8 | - How do I bind a Kotlin library to .NET? |
| 9 | - How do I bind a Java library to .NET? |
| 10 | - How do I integrate an AAR or JAR into .NET MAUI? |
| 11 | - How do I create a Java/Kotlin wrapper for a native Android library? |
| 12 | - How do I update Android bindings when the native SDK changes? |
| 13 | - How do I fix Android binding build errors? |
| 14 | - How do I expose native Android APIs to C#? |
| 15 | - How do I resolve Maven dependencies for Android bindings? |
| 16 | - How do I handle AndroidX dependencies in bindings? |
| 17 | - How do I fix "Java dependency is not satisfied" errors? |
| 18 | - How do I use AndroidMavenLibrary in my binding project? |
| 19 | |
| 20 | # Overview |
| 21 | |
| 22 | 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. |
| 23 | |
| 24 | ## When to Use Slim Bindings vs Traditional Bindings |
| 25 | |
| 26 | | Scenario | Recommended Approach | |
| 27 | |----------|---------------------| |
| 28 | | Need only a subset of library functionality | **Slim Bindings** ✓ | |
| 29 | | Easier maintenance when SDK updates | **Slim Bindings** ✓ | |
| 30 | | Prefer working in Java/Kotlin for wrapper | **Slim Bindings** ✓ | |
| 31 | | Better isolation from breaking changes | **Slim Bindings** ✓ | |
| 32 | | Complex libraries with many dependencies | **Slim Bindings** ✓ | |
| 33 | | Need entire library API surface | Traditional Bindings | |
| 34 | | Creating bindings for third-party developers | Traditional Bindings | |
| 35 | | Already maintaining traditional bindings | Traditional Bindings | |
| 36 | |
| 37 | # Inputs |
| 38 | |
| 39 | | Parameter | Required | Example | Notes | |
| 40 | |-----------|----------|---------|-------| |
| 41 | | libraryName | yes | `FirebaseMessaging`, `OkHttp` | Name of the native Android library to bind | |
| 42 | | bindingProjectName | yes | `MyBinding.Android` | Name for the C# binding project | |
| 43 | | dependencySource | no | `maven`, `aar`, `jar` | How the native library is distributed | |
| 44 | | targetFrameworks | no | `net9.0-android` | Target frameworks (default: latest .NET Android) | |
| 45 | | exposedApis | no | List of specific APIs | Which native APIs to expose (helps scope the wrapper) | |
| 46 | | mavenCoordinates | no | `com.example:library:1.0.0` | Maven coordinates if library is from Maven repository | |
| 47 | |
| 48 | # Project Structure |
| 49 | |
| 50 | The recommended project structure for Native Library Interop: |
| 51 | |
| 52 | ``` |
| 53 | MyBinding/ |
| 54 | ├── android/ |
| 55 | │ ├── native/ # Android Studio/Gradle project |
| 56 | │ │ ├── app/ |
| 57 | │ │ │ ├── src/main/ |
| 58 | │ │ │ │ └── java/com/example/mybinding/ |
| 59 | │ │ │ │ └── DotnetMyBinding.java # Java wrapper implementation |
| 60 | │ │ │ │ └── kotlin/com/example/mybinding/ |
| 61 | │ │ │ │ └── DotnetMyBinding.kt # Or Kotlin wrapper |
| 62 | │ │ │ └── build.gradle.kts |
| 63 | │ │ ├── settings.gradle.kts |
| 64 | │ │ └── build.gradle.kts |
| 65 | │ └── MyBinding.Android.Binding/ |
| 66 | │ ├── MyBinding.Android.Binding.csproj |
| 67 | │ └── Transforms/ |
| 68 | │ └── Metadata.xml |
| 69 | ├── sample/ |
| 70 | │ └── MauiSample/ # Sample MAUI app |
| 71 | │ ├── MauiSample.csproj |
| 72 | │ └── MainPage.xaml.cs |
| 73 | └── README.md |
| 74 | ``` |
| 75 | |
| 76 | # Step-by-step Process |
| 77 | |
| 78 | ## Step 1: Analyze Dependencies First |
| 79 | |
| 80 | 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. |
| 81 | |
| 82 | ### Prerequisites |
| 83 | |
| 84 | Ensure you have: |
| 85 | - JDK 17+ |
| 86 | - Android SDK with `ANDROID_HOME` environment variable set |
| 87 | - .NET SDK 9+ (recommended for Java Dependency Verification) |
| 88 | |
| 89 | > **Note:** You don't need Gradle installed globally—we'll use the Gradle Wrapper which downloads the correct version automatically. |
| 90 | |
| 91 | ## Step 2: Create the Android Library Project |
| 92 | |
| 93 | There are multiple approaches to create the native Android wrapper project. Choose the one that best fits your workflow. |
| 94 | |
| 95 | ### Option A: Use Android Studio (Recommended for GUI) |
| 96 | |
| 97 | The most reliable way to create a properly configured Android library: |
| 98 | |
| 99 | 1. **Open Android Studio** |
| 100 | 2. **File → New → New Project** |
| 101 | 3. Select **"No Activity"** template |
| 102 | 4. Configure: |
| 103 | - Name: `MyBindingNative` |
| 104 | - Package name: `com.example.mybinding` |
| 105 | - Language: Java or Kotlin |
| 106 | - Minimum SDK: API 21 |
| 107 | 5. **File → New → New Module** |
| 108 | 6. Select **"Android Library"** |
| 109 | 7. Name it `app` (or your preferred |