Skip to main content
Glama

dhis2_android_configure_gradle

Generate Gradle build configuration for integrating DHIS2 Android SDK into Android projects, including version management, build features, and environment-specific variants.

Instructions

Generate Gradle build configuration for DHIS2 Android SDK integration

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dhis2SdkVersionYesDHIS2 Android SDK version
buildFeaturesNo
proguardRulesNoGenerate ProGuard rules for DHIS2 SDK
buildVariantsNoBuild variants for different DHIS2 environments
additionalLibrariesNoAdditional Android libraries to include

Implementation Reference

  • Main execution handler for the tool. Receives arguments via MCP CallToolRequest, calls the generateGradleBuildConfig helper function, and returns the generated configuration as markdown text content.
    case 'dhis2_android_configure_gradle':
      const gradleArgs = args as any;
      const gradleConfig = generateGradleBuildConfig(gradleArgs);
      return {
        content: [
          {
            type: 'text',
            text: gradleConfig,
          },
        ],
      };
  • Primary helper function that generates complete Android Gradle build configurations tailored for DHIS2 SDK integration, including dependencies, build features (Compose, ViewBinding, DataBinding), product flavors for DHIS2 instances, ProGuard rules, and additional libraries like Room, Retrofit, Hilt.
    export function generateGradleBuildConfig(config: GradleConfig): string {
      const { dhis2SdkVersion, buildFeatures, proguardRules, buildVariants, additionalLibraries } = config;
    
      const additionalDependencies = additionalLibraries.map(lib => {
        switch (lib) {
          case 'room':
            return `    // Room Database
        implementation "androidx.room:room-runtime:2.6.1"
        implementation "androidx.room:room-ktx:2.6.1"
        kapt "androidx.room:room-compiler:2.6.1"`;
          case 'retrofit':
            return `    // Retrofit HTTP Client  
        implementation "com.squareup.retrofit2:retrofit:2.9.0"
        implementation "com.squareup.retrofit2:converter-gson:2.9.0"`;
          case 'dagger_hilt':
            return `    // Dagger Hilt
        implementation "com.google.dagger:hilt-android:2.48"
        kapt "com.google.dagger:hilt-compiler:2.48"`;
          case 'rxjava':
            return `    // RxJava
        implementation "io.reactivex.rxjava3:rxjava:3.1.8"
        implementation "io.reactivex.rxjava3:rxandroid:3.0.2"`;
          case 'coroutines':
            return `    // Kotlin Coroutines
        implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3"
        implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3"`;
          case 'navigation':
            return `    // Navigation Component
        implementation "androidx.navigation:navigation-fragment-ktx:2.7.6"
        implementation "androidx.navigation:navigation-ui-ktx:2.7.6"`;
          default:
            return '';
        }
      }).filter(dep => dep).join('\n\n');
    
      return `# Android Gradle Build Configuration
    
    ## app/build.gradle.kts
    
    \`\`\`kotlin
    plugins {
        id("com.android.application")
        id("org.jetbrains.kotlin.android")
    ${buildFeatures.compose ? '    id("org.jetbrains.kotlin.plugin.compose")' : ''}
    ${additionalLibraries.includes('dagger_hilt') ? '    id("dagger.hilt.android.plugin")' : ''}
        kotlin("kapt")
    }
    
    android {
        namespace = "${config.dhis2SdkVersion}"  // Use your package name
        compileSdk = 34
    
        defaultConfig {
            applicationId = "org.dhis2.android.app"
            minSdk = 21
            targetSdk = 34
            versionCode = 1
            versionName = "1.0"
    
            testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
    ${buildFeatures.compose ? `        
            vectorDrawables {
                useSupportLibrary = true
            }` : ''}
        }
    
        buildTypes {
            release {
                isMinifyEnabled = ${proguardRules}
                ${proguardRules ? 'proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")' : ''}
            }
            debug {
                isMinifyEnabled = false
                applicationIdSuffix = ".debug"
                versionNameSuffix = "-DEBUG"
            }
        }
    
        ${buildVariants.length > 0 ? `
        flavorDimensions += "environment"
        productFlavors {${buildVariants.map(variant => `
            create("${variant.name}") {
                dimension = "environment"
                buildConfigField("String", "DHIS2_BASE_URL", "\\"${variant.dhis2Instance}\\"")
                applicationIdSuffix = ".${variant.name}"
            }`).join('')}
        }` : ''}
    
        compileOptions {
            sourceCompatibility = JavaVersion.VERSION_1_8
            targetCompatibility = JavaVersion.VERSION_1_8
        }
        
        kotlinOptions {
            jvmTarget = "1.8"
        }
    
        buildFeatures {
    ${buildFeatures.compose ? '        compose = true' : ''}
    ${buildFeatures.viewBinding ? '        viewBinding = true' : ''}  
    ${buildFeatures.dataBinding ? '        dataBinding = true' : ''}
            buildConfig = true
        }
    
    ${buildFeatures.compose ? `    composeOptions {
            kotlinCompilerExtensionVersion = "1.5.8"
        }` : ''}
    
        packaging {
            resources {
                excludes += "/META-INF/{AL2.0,LGPL2.1}"
            }
        }
    }
    
    dependencies {
        // DHIS2 Android SDK
        implementation "org.hisp.dhis:android-core:${dhis2SdkVersion}"
        
        // Core Android Dependencies
        implementation "androidx.core:core-ktx:1.12.0"
        implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.7.0"
        implementation "androidx.activity:activity-ktx:1.8.2"
        
    ${buildFeatures.compose ? `    // Jetpack Compose
        implementation platform("androidx.compose:compose-bom:2024.02.00")
        implementation "androidx.compose.ui:ui"
        implementation "androidx.compose.ui:ui-graphics"
        implementation "androidx.compose.ui:ui-tooling-preview"
        implementation "androidx.compose.material3:material3"
        implementation "androidx.activity:activity-compose:1.8.2"
        
        debugImplementation "androidx.compose.ui:ui-tooling"
        debugImplementation "androidx.compose.ui:ui-test-manifest"` : ''}
    
    ${!buildFeatures.compose ? `    // Traditional Android Views
        implementation "com.google.android.material:material:1.11.0"
        implementation "androidx.constraintlayout:constraintlayout:2.1.4"` : ''}
    
        // Lifecycle Components
        implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0"
        implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.7.0"
    
    ${additionalDependencies}
    
        // Testing
        testImplementation "junit:junit:4.13.2"
        testImplementation "org.mockito:mockito-core:5.7.0"
        testImplementation "androidx.arch.core:core-testing:2.2.0"
        
        androidTestImplementation "androidx.test.ext:junit:1.1.5"
        androidTestImplementation "androidx.test.espresso:espresso-core:3.5.1"
    ${buildFeatures.compose ? `    androidTestImplementation "androidx.compose.ui:ui-test-junit4"` : ''}
    }
    \`\`\`
    
    ## Project Level build.gradle.kts
    
    \`\`\`kotlin
    plugins {
        id("com.android.application") version "8.2.2" apply false
        id("org.jetbrains.kotlin.android") version "1.9.22" apply false
    ${additionalLibraries.includes('dagger_hilt') ? '    id("com.google.dagger.hilt.android") version "2.48" apply false' : ''}
    ${buildFeatures.compose ? '    id("org.jetbrains.kotlin.plugin.compose") version "1.9.22" apply false' : ''}
    }
    \`\`\`
    
    ${proguardRules ? generateProGuardRules() : ''}
    
    ## gradle.properties
    
    \`\`\`properties
    # Android Configuration
    android.useAndroidX=true
    android.enableJetifier=true
    
    # Kotlin Configuration  
    kotlin.code.style=official
    
    # Performance Optimizations
    org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
    org.gradle.parallel=true
    org.gradle.caching=true
    org.gradle.configureondemand=true
    
    # DHIS2 Configuration
    DHIS2_SDK_VERSION=${dhis2SdkVersion}
    \`\`\`
    
    ## Next Steps
    
    1. **Sync project** - Click "Sync Now" in Android Studio
    2. **Configure authentication** - Use \`dhis2_android_setup_authentication\`  
    3. **Set up data models** - Use \`dhis2_android_generate_data_models\`
    4. **Configure sync** - Use \`dhis2_android_setup_sync\`
    `;
  • TypeScript interface defining the input schema/parameters for Gradle configuration: DHIS2 SDK version, build features, ProGuard settings, environment-specific build variants, and optional libraries.
    export interface GradleConfig {
      dhis2SdkVersion: string;
      buildFeatures: {
        compose?: boolean;
        viewBinding?: boolean;
        dataBinding?: boolean;
      };
      proguardRules: boolean;
      buildVariants: Array<{
        name: string;
        dhis2Instance: string;
      }>;
      additionalLibraries: string[];
    }
  • Tool permission registration in TOOL_PERMISSIONS Map. Maps 'dhis2_android_configure_gradle' to 'canUseMobileFeatures' permission, used by PermissionSystem.filterToolsByPermissions() to control tool visibility based on user authorities.
    ['dhis2_android_init_project', 'canUseMobileFeatures'],
    ['dhis2_android_configure_gradle', 'canUseMobileFeatures'],
    ['dhis2_android_setup_sync', 'canConfigureMobile'],
    ['dhis2_android_configure_storage', 'canConfigureMobile'],
    ['dhis2_android_setup_location_services', 'canUseMobileFeatures'],
    ['dhis2_android_configure_camera', 'canUseMobileFeatures'],
    ['dhis2_android_setup_authentication', 'canConfigureMobile'],
    ['dhis2_android_generate_data_models', 'canUseMobileFeatures'],
    ['dhis2_android_setup_testing', 'canUseMobileFeatures'],
    ['dhis2_android_configure_ui_patterns', 'canUseMobileFeatures'],
    ['dhis2_android_setup_offline_analytics', 'canUseMobileFeatures'],
    ['dhis2_android_configure_notifications', 'canUseMobileFeatures'],
    ['dhis2_android_performance_optimization', 'canUseMobileFeatures'],
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states the tool 'generates' configuration, implying a write operation, but doesn't specify whether this modifies existing files, creates new ones, or requires specific permissions. It also lacks details on output format, error handling, or any side effects. The description adds minimal behavioral context beyond the basic action.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's front-loaded with the core action and context, making it easy to parse. There's no redundancy or fluff, earning full marks for conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (5 parameters with nested objects) and lack of annotations and output schema, the description is minimally adequate. It identifies the tool's domain but doesn't compensate for missing behavioral details or output information. For a configuration-generation tool with multiple parameters, more context on what the generated output looks like or how it should be used would be helpful.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description doesn't mention any parameters, but the input schema has 80% description coverage, providing clear documentation for most parameters. The schema covers key aspects like SDK version, build features, and build variants. However, the description doesn't add any semantic context beyond what's in the schema, such as explaining why certain parameters are important or how they interact.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Generate Gradle build configuration for DHIS2 Android SDK integration'. It specifies the action (generate), resource (Gradle build configuration), and context (DHIS2 Android SDK integration). However, it doesn't explicitly differentiate from sibling tools like 'dhis2_configure_build_system' or 'dhis2_android_init_project', which may have overlapping functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, appropriate contexts, or how it differs from related tools such as 'dhis2_android_init_project' (which might handle broader project setup) or 'dhis2_configure_build_system' (which could be more general). This leaves the agent without clear usage boundaries.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Dradebo/dhis2-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server