After Update To Android Studio 2.2 / Gradle Plugin 2.2.0: "could Not Get Unknown Property 'assemblerelease'"
Solution 1:
tasks.whenTaskAdded { task ->if (task.name == 'assembleRelease') {
task.finalizedBy 'yourRenameTasks'
}
}
Solution 2:
You may rewrite your task a bit and try like this:
task renameBuildTask() << {
file('build/outputs/apk/app-release.apk').renameTo("AppName-1.0.0-${project.ext.androidVersionCode}.apk")
dependsOn 'assembleRelease'
}
Also you can check this question to get better understanding.
EDIT
As @tangens said in a comment:
It works when I replace the call gradle assemble by e.g. gradle renameBuildTask. Thank you! The answer contains an error. Correct would be: task renameBuildTask() << { ... }
Solution 3:
maybe wrap code in afterEvaluate{} will be work:
afterEvaluate {
assembleRelease.doLast {
file('build/outputs/apk/app-release.apk').renameTo("AppName-1.0.0-${project.ext.androidVersionCode}.apk")
}
}
gradle-2.14.1 and android gradle plugin 2.2.0
details: Could not get unknown property 'assembleDebug' (2.2-beta)
Solution 4:
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.
Solution 5:
inside buildTypes {} method, I put this code : worked like a charm
task setEnvRelease << {
ant.propertyfile(
file: "src/main/assets/build.properties") {
entry(key: "EO_WS_DEPLOY_ADDR", value: "http://PRODUCTION IP")
}
}
task setEnvDebug << {
ant.propertyfile(
file: "src/main/assets/build.properties") {
entry(key: "EO_WS_DEPLOY_ADDR", value: "http://DEBUG IP TEST")
}
}
tasks.whenTaskAdded { task ->
if (task.name == 'assembleDebug') {
task.dependsOn'setEnvDebug'
} elseif (task.name == 'assembleRelease') {
task.dependsOn'setEnvRelease'
}
}
Post a Comment for "After Update To Android Studio 2.2 / Gradle Plugin 2.2.0: "could Not Get Unknown Property 'assemblerelease'""