1

I am using Android studio & using Gradle as build tool. In my build.gradle, I defined a custom task:

def myTask {
  ...
}

I would like to run the task right after the class.dex file is generated. I tried:

myTask.dependsOn(dex)

Gradle gives error: Could not find property 'dex'

Then, I tried:

myTask.dependsOn(dexDebug)

Gradle gives error: Could not find property 'dexDebug'

My questions are:

  1. Why I got this error? I see at least there is a task named dexDebug in task list. Why I cannot depends my task on it?

  2. How to define my task to run right after class.dex file is generated then?

(I am using Gradle Android Plugin v1.0.0, Gradle v2.2.1)

user842225
  • 5,445
  • 15
  • 69
  • 119
  • Note that making your task depend on dexDebug won't cause it to be run after each time dexDebug runs -- it insures that if you invoke your task explicitly, dexDebug will be run first. – Scott Barta Jan 16 '15 at 17:55
  • I know that, actually I have also build.dependsOn(myTask) which ensures they all run – user842225 Jan 19 '15 at 09:10
  • @ScottBarta, why you think my question is duplicated with the one you linked? We are asking different things, in my question I said I can see the task dexDebug listed in gradle while the question in your link is trying to run task which is not listed. Please check my question carefully & remove the "mark as duplicated". You blocked me from starting a bounty . – user842225 Jan 19 '15 at 09:17
  • 1
    Your question is slightly different, but not in any essential details compared to the linked question -- that questioner is trying to set up a dependency on an Android Gradle task that doesn't exist during the phase of execution where the dependency was being set up, and the answer is to put it in a `gradle.projectsEvaluated` block. – Scott Barta Jan 19 '15 at 17:59

0 Answers0