Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does downloadApolloSchema support android product flavor? #2710

Closed
jeffxchu opened this issue Oct 29, 2020 · 2 comments · Fixed by #2712
Closed

Does downloadApolloSchema support android product flavor? #2710

jeffxchu opened this issue Oct 29, 2020 · 2 comments · Fixed by #2712

Comments

@jeffxchu
Copy link

jeffxchu commented Oct 29, 2020

Question.
In my project, I have set up both buildType and product flavors e.g.

buildTypes {
    getByName("release") {
      isMinifyEnabled = true
      proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
      isDebuggable = false
    }
    getByName("debug") {
      applicationIdSuffix(".debug")
      versionNameSuffix("-debug")
      isDebuggable = true
    }
  }

  flavorDimensions("mode")
  productFlavors {
    create("local") {
      dimension = "mode"
      applicationIdSuffix(".local")
      versionNameSuffix("-local")
      buildConfigField("String", "GRAPHQL_API", "\"https://local.abc.io/graphql\"")
    }
    create("staging") {
      dimension = "mode"
      applicationIdSuffix(".staging")
      versionNameSuffix("-staging")
      buildConfigField("String", "GRAPHQL_API", "\"https://staging.abc.io/graphql\"")
    }
  }

When I ran

./gradlew downloadApolloSchema --endpoint="..." --schema="..."

I got

> Task :app:downloadApolloSchema FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:downloadApolloSchema'.
> Cannot find compilation unit, check variant and service.
  Possible services:
  service
  Possible variants:
  localDebug
  localDebugAndroidTest
  localDebugUnitTest
  localRelease
  localReleaseUnitTest

I can't find a way to resolve this error. If I remove the product flavor {}, I am able to download the schema.json again. I'm wondering if there are any workarounds for this issue.

martinbonnin added a commit that referenced this issue Oct 29, 2020
* relax the condition on variant name to find the default schema
  location
* always allow to override it with the `--schema` option

closes #2710
@martinbonnin
Copy link
Contributor

Sorry about that, this was an oversight. --schema should always allow to override the compilation unit automatic detection.

A fix is in #2712.

In the meantime, you should be able to workaround this by passing the variant explicitely:

./gradlew downloadApolloSchema --endpoint="..." --schema="..." --variant="localRelease"

@jeffxchu
Copy link
Author

Sorry about that, this was an oversight. --schema should always allow to override the compilation unit automatic detection.

A fix is in #2712.

In the meantime, you should be able to workaround this by passing the variant explicitely:

./gradlew downloadApolloSchema --endpoint="..." --schema="..." --variant="localRelease"

great. thanks for fixing this issue @martinbonnin

martinbonnin added a commit that referenced this issue Nov 2, 2020
* relax the condition on variant name to find the default schema
  location
* always allow to override it with the `--schema` option

closes #2710
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants