23

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

Error:(32, 1) A problem occurred evaluating project ':jobdispatcher'. Could not get unknown property 'assembleRelease' for project ':jobdispatcher' of type org.gradle.api.Project.

The problem is in the build.gradle file of an imported jobdispatcher module:

task aar(dependsOn: assembleRelease)

What changes can I make to fix this?

Note, this issue is very similar to, but still a bit different to, that reported here.

Community
  • 1
  • 1
drmrbrewer
  • 11,491
  • 21
  • 85
  • 181
  • Was using android 2.3.0 release to build it on Ubuntu: open Android Studio 2.3, then "Import project ( Eclipse, Ant )", android studio will ask for creating wrappers, let it do it; once that is done, change buildWithMake = true inside build.gradle(this could be done earlier). then "Build" --> "Build APK", I could get the APK build and load. May you try it? I will check on 2.2.0 also and update you. – Gerry Mar 27 '17 at 23:14
  • yeah, saw it with "run" button path. it is fixed now. thx – Gerry Mar 28 '17 at 16:36

5 Answers5

23

Move your dependency dependsOn inside your gradle task like shown below:

task aar() << {
    dependsOn 'assembleRelease'
}
Volodymyr
  • 6,393
  • 4
  • 53
  • 84
22

Just add "" like this to fix your problem:

from:

task aar(dependsOn: assembleRelease)

to:

task aar(dependsOn: "assembleRelease")
lopez.mikhael
  • 9,943
  • 19
  • 67
  • 110
  • I was using single quotes... and I was thinking... what on earth am I doing wrong? Thanks for this! – Displee Jan 15 '20 at 10:22
11

I tried all the previous answers, all are not working. Here is the one working after gradle 2.2. Starting from 2.2, those tasks also include "assembleDebug" and "assembleRelease". To access such tasks, the user will need to use an afterEvaluate closure:

afterEvaluate {
    task aar(dependsOn: assembleRelease) {
          //task
    }
}
Weidian Huang
  • 2,787
  • 2
  • 20
  • 29
0
task aar {
    ....
}

aar.dependsOn('assembleRelease')

and task aar will run after task "assembleRelease" finished~

wish this will help you~ :-D

fantianwen
  • 21
  • 3
0

I had the same problem.

Disabling instant run under Android Studio/Preferences/Build, Execution, Deployment/Instant Run worked for me.

Jared Forth
  • 1,577
  • 6
  • 17
  • 32