GardenMobile & interfaces

An old Android annotation-processor Gradle migration

A recorded workaround for a build-script failure around the Android Gradle plugin 3 transition.

An Android build-script upgrade can fail before application code compiles. This older note recorded a problem around the Android Gradle plugin 3 transition, where the project still used this apt configuration:

apt {
    arguments {
        androidManifestFile variant.outputs[0]?.processResources?.manifestFile
        resourcePackageName android.defaultConfig.applicationId
    }
}

The recorded workaround

The replacement moved the annotation-processor arguments into the application-variant configuration:

applicationVariants.all { variant ->
    variant.outputs.all {
        outputFileName = "tacko-" + "${variant.productFlavors[0].name}.apk"
    }
    variant.variantData.variantConfiguration.javaCompileOptions.annotationProcessorOptions.arguments =
            ['androidManifestFile': variant.outputs[0]?.processResources?.manifestFile?.absolutePath,
            'resourcePackageName': android.defaultConfig.applicationId]
}

The output filename and flavor indexing belong to the original application. The workaround also reaches into plugin internals such as variantData, so it should not be treated as a stable interface for later Android Gradle plugin versions.

This is a historical troubleshooting record. Matching the error text alone is not enough to establish that the same workaround fits a different Gradle, plugin, or annotation-processor version.

← Back to the garden