1

After installing InstantRun the project could not compile any more with the following Gradle configuration error:

Could not get unknown property 'assembleRelease' for object of type com.android.build.gradle.internal.api.ApplicationVariantImpl.

Gradle previous code:

afterEvaluate {
    assembleDebug.doLast {
        copyApk(project.name, project.name, "debug")
    }
    assembleRelease.doLast {
        copyApk(project.name, project.name, "release")
    }
}

It seems the property assembleRelease do not exist under InstantRun, so the Gradle configuration file should be patched in this way:

afterEvaluate {
        assembleDebug.doLast {
            copyApk(project.name, project.name, "debug")
        }
        if (project.hasProperty("assembleRelease")) {
            assembleRelease.doLast {
                copyApk(project.name, project.name, "release")
            }
        }
    }
MartinLoren
  • 61
  • 1
  • 6

1 Answers1

0

Before making the build, check if you have instant run enabled or not. It is enabled by default and can be found under

File -> Settings -> Build,Execution,Deployment -> Instant Run

Disable it and then try rebuilding the APK.

For more, you can visit this: android studio 2.3 instant run not working

Faysal Ahmed
  • 7,501
  • 5
  • 28
  • 50
  • It should be a recent change in InstantRun since previously it did not require this change. I'm running Android Studio 3.1.3. – MartinLoren Aug 02 '18 at 08:57