Why is there no assetsDir attribute in ProcessAndroidResources?

In my gradle construct for an Android app, I have the following code to copy a bunch of images that are generated during assembly into the directory of /assets/the APK file:

android.applicationVariants.all { variant -> 
variant.mergeResources.doLast {
    variant.outputs.each { output ->  
        copy {
            from file("${project.buildDir}/" + "generated_images")
            into output.processResources.assetsDir
        }
    } 
}

def mergeAssets = tasks.getByPath("merge" + "${variant.name.capitalize()}" + "Assets")
mergeAssets.dependsOn(generateAssetImages)

}

Error message:

* What went wrong:
Execution failed for task ':app:mergeVariant1Resources'.
> Could not get unknown property 'assetsDir' for task     ':app:processVariant1Resources' of
type com.android.build.gradle.tasks.ProcessAndroidResources.

This one works fine , but after upgrading from buildToolsVersion "23.0.3"to buildToolsVersion "25.0.2", output.processResources.assetsDirit is undefined.

What changed? Why is assetsDir no longer a "known property"?

Or what's a good way to get assetsDir so that I can copy stuff to this directory? It works if I copy the generated assets to build\intermediates\assets\{INSERT_VARIANT_NAME_HERE}\at build time. My workaround is to get assetDir as follows:

def assetsDir = output.processResources.resDir.toString().replace("res\\merged", "assets")

It works now, but I'm really unhappy about it.

+4

Source: https://habr.com/ru/post/1670692/


All Articles