Triple-T / gradle-play-publisher

GPP is Android's unofficial release automation Gradle Plugin. It can do anything from building, uploading, and then promoting your App Bundle or APK to publishing app listings and other metadata.
MIT License
4.13k stars 341 forks source link

Could not get unknown property 'ReleaseStatus' for extension 'play' #885

Closed kioli closed 3 years ago

kioli commented 4 years ago

Describe the bug

I've recently migrated from 2.3.0 to 3.0.0 and I changed my build.gradle file accordingly going from this

play {
    track = "beta"
    releaseStatus = "inProgress"
    userFraction = 1
    serviceAccountCredentials = file("credentials.json")
}

to this

play {
    track.set("beta")
    userFraction.set(new Double(1))
    releaseStatus.set(ReleaseStatus.IN_PROGRESS)
    serviceAccountCredentials.set(file("credentials.json"))
}

But when I try to build my app I am presented with the following error

Could not get unknown property 'ReleaseStatus' for extension 'play' of type com.github.triplet.gradle.play.PlayPublisherExtension.

How To Reproduce

Include the play closure to the build.gradle file and sync

Versions

Tasks executed

It fails when syncing after modifying the play closure

Expected behavior

I would expect the sync to be successful

SUPERCILEX commented 4 years ago

Hmmm, looks like I need to update the docs for this. Someone else just asked the same thing: https://github.com/Triple-T/gradle-play-publisher/issues/827#issuecomment-725673682

kioli commented 4 years ago

Right I forgot, I also use the plugin block

plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-android-extensions'
    id 'kotlin-kapt'
    id 'com.google.firebase.appdistribution'
    id 'com.google.gms.google-services'
    id 'com.github.triplet.play'
}

If I simply add the line import com.github.triplet.gradle.androidpublisher.ReleaseStatus in the file it does sync and build, though the line has the ReleaseStatus coloured in red and, despite the file syncing and allowing me to perform ./gradlew commands, it still shows as faulty with a wiggly red line under its filename

SUPERCILEX commented 4 years ago

Invalidate caches and restart? 😝 If it works in Gradle, that's an IntelliJ problem and not related to this project.

kioli commented 4 years ago

It doesn't solve it unfortunately But all I can say so far is that it just wrong, but it does work 👍 Thanks for your help and your great work

SUPERCILEX commented 4 years ago

Bummer, hopefully an update to Studio or IntelliJ will fix it.

SUPERCILEX commented 4 years ago

Note to self: also add comment about user fraction needing a d in groovy.

underwindfall commented 3 years ago

I know this issue has been closed. But about the red lint was raised here , properly could be resovled by something like this

    play {
        ......
        //releaseStatus is the type of release, i.e. ReleaseStatus.[COMPLETED/DRAFT/HALTED/IN_PROGRESS]
        releaseStatus.set(com.github.triplet.gradle.androidpublisher.ReleaseStatus.DRAFT) 
        ......
    }
btseytlinTCP commented 3 years ago

In gradle+androidstudio, i had to use the fully qualified "com.github.triplet.gradle.androidpublisher.ReleaseStatus.DRAFT" like you posted here. @SUPERCILEX Since import statement wasn't working for me, it would be helpful to add to the readme as part of migration to 3+

micer commented 3 years ago

Even with the fully qualified name of ReleaseStatus.DRAFT as @btseytlinTCP suggested, I'm still getting an error: Caused by: groovy.lang.MissingPropertyException: Could not get unknown property 'com' for extension 'play' of type com.github.triplet.gradle.play.PlayPublisherExtension.

When I remove releaseStatus property setter, there's no issue. I tried to invalidate caches and restart Android Studio, tried to run gradle build --no-build-cache, nothing works. Any idea how to fix this?

btseytlinTCP commented 3 years ago

@micer Perhaps your import is on the wrong fields? Example:

play {
    releaseStatus.set(com.github.triplet.gradle.androidpublisher.ReleaseStatus.COMPLETED)
    resolutionStrategy.set(com.github.triplet.gradle.androidpublisher.ResolutionStrategy.AUTO)
}
micer commented 3 years ago

@btseytlinTCP nope, seems to be correct:

apply plugin: 'com.github.triplet.play'

android {
    playConfigs {
        europeUkRelease {
            enabled.set(true)
        }
    }
}

play {
    enabled.set(false)
    serviceAccountCredentials.set(file("${rootDir}/../../android.json"))
    track.set("production")
    releaseStatus.set(com.github.triplet.gradle.androidpublisher.ReleaseStatus.DRAFT)
}

I have this in separated gradle file and added to module's build.gradle with apply from: "${rootDir}/gradle/google_play_publisher.gradle", but that shouldn't be a problem.

btseytlinTCP commented 3 years ago

i'd try

  1. moving to plugins{} instead of apply plugin:
    plugins {
    id("com.github.triplet.play") version("3.2.0")
    }
  2. Try sanity checking by moving it into the module's build.gradle file to circumvent the apply from thing you're doing and isolate the issue further
SUPERCILEX commented 3 years ago

Yeah, for whatever reason I don't think Gradle lets you use imports outside of the build.gradle file.

micer commented 3 years ago

Yes, moving all to module's build.gradle works! 🤯 Thanks guys!

xsveda commented 3 years ago

For anyone having the same issue and using Triple-T plugin in buildSrc, this might help you.

We put the plugin on classpath in buildSrc/build.gradle.kts like this:

dependencies {
    implementation("com.github.triplet.gradle:play-publisher:3.3.0-agp4.2")
}

To have ReleaseStatus constants available you need to add aditional android-publisher module on classpath in buildSrc/build.gradle.kts:

dependencies {
    implementation("com.github.triplet.gradle:play-publisher:3.3.0-agp4.2")
    implementation("com.github.triplet.gradle:android-publisher:3.3.0-agp4.2")
}
SUPERCILEX commented 2 years ago

See #1039 for a proper fix.