title: Android Studio custom gradle task with dependencies - "Could not get unknown property"
body: <p>I'm using a library that supplies gradle tasks to upload builds to HockeyApp (<a href="https://github.com/x2on/gradle-hockeyapp-plugin" rel="nofollow noreferrer">https://github.com/x2on/gradle-hockeyapp-plugin</a>).  I think what it does specifically isn't important, just that it creates tasks.  I can run those tasks no problem.  I wanted to create a task to run several of these custom tasks at once.  The upload tasks are named like <code>upload[BuildVariant]ToHockeyApp</code> and it created one for each build variant.  My custom task, defined in <code>android</code> in the project level gradle file, looks like this:</p>
  
  <pre><code>task uploadLegacyReleaseToHockeyApp(dependsOn:
              uploadVariant1ReleaseToHockeyApp,
              uploadVariant2ReleaseToHockeyApp,
              // etc
        ){}
  </code></pre>
  
  <p>When syncing the gradle file, I get this error: </p>
  
  <p><code>Error:(89, 0) Could not get unknown property 'uploadVariant1ReleaseToHockeyApp' for object of type com.android.build.gradle.AppExtension.</code></p>
  
  <p>I've triple checked there are no typos and the task in the error message actually exists. Am I doing something wrong, or is it not possible to write a dependency on a task that's dynamically generated like this?  I don't really know how the plugin works, but it creates its own task group with automatically generated tasks in it.</p>
  
  <p><strong>UPDATE based on the answer from lukegv:</strong></p>
  
  <p>If I use the <code>dependsOn</code> method I get this error: <code>Error:(90, 0) Could not get unknown property 'uploadVariant1ToHockeyApp' for task ':app:uploadLegacyReleaseToHockeyApp' of type org.gradle.api.DefaultTask.</code>  </p>
  
  <p>With the constructor:</p>
  
  <pre><code>task uploadLegacyReleaseToHockeyApp(dependsOn:
              'uploadVariant1ToHockeyApp',
              'uploadVariant2ToHockeyApp',
              // etc
  </code></pre>
  
  <p>I got this: <code>Could not find method uploadLegacyReleaseToHockeyApp() for arguments [{dependsOn=uploadVariant1ToHockeyApp}, uploadVariant2ToHockeyApp,...</code> </p>
  
  <p>Note the first item is in curly braces and the rest are not.</p>
  
  <p>If I put all the task names in a single string, it successfully syncs the build files, but the string is interpreted as a single task name so running it fails.</p>