From the migration guide :
Using the API to control output options breaks down with the new plugin. It still works for simple tasks, such as changing the name of the APK during build, as shown below:
// If you use each() to iterate through the variant objects, // you need to start using all(). That because each() iterates // through only the objects that already exist during configuration timeโ // but those object don't exist at configuration time with the new model. // However, all() adapts to the new model by picking up object as they are // added during execution. android.applicationVariants.all { variant -> variant.outputs.all { outputFileName = "${variant.name}-${variant.versionName}.apk" } }
However, more complex tasks associated with accessing outputFile objects no longer work. This is because, at the configuration stage, specific tasks are no longer created. This leads to the fact that the plugin does not know all its outputs in front, but it also means faster setup time. As an alternative, we will introduce new APIs to provide similar functionality.
source share