After updating Android Studio to version 2.2 and the Gradle-plugin to 2.2.0, I get following error:
I had the same problem after upgrading Android Studio to 2.2 and Gradle to 2.2. I have task copyApk that needs to be run at the end of building. For brevity, let me skip what was working before, and post only what is working right now:
tasks.create(name: 'copyApk', type: Copy) {
from 'build/outputs/apk/myapp-official-release.apk'
into '.../mobile'
rename('myapp-official-release.apk', 'myapp.apk')
}
tasks.whenTaskAdded { task ->
if (task.name == 'assembleRelease') {
task.dependsOn 'copyApk'
}
}
Gradle console shows copyApk was run near the end after packageOfficialRelease, assembleOfficialRelease, right before the last task assembleRelease. "Official" is a flavor of the app. I got the workaround from this SO post. I essentially copied the answer here for your convenience. All credits go to the author of that post.