After update to Android Studio 2.2 / gradle plugin 2.2.0: “could not get unknown property 'assembleRelease'”

前端 未结 6 1030
没有蜡笔的小新
没有蜡笔的小新 2020-12-29 23:48

After updating Android Studio to version 2.2 and the Gradle-plugin to 2.2.0, I get following error:

6条回答
  •  清歌不尽
    2020-12-30 00:28

    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.

提交回复
热议问题