title: Gradle: Could not get unknown property
body: <p>Already defined the repository variables needed.</p>
  <p><a href="https://i.stack.imgur.com/Pw69w.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Pw69w.png" alt="enter image description here" /></a></p>
  <p>This is the Gradle wrapper command in the pipeline</p>
  <pre><code>- step:
          name: Create Keystores and Google Play API key file
          script:
            - mkdir keys # create new directory
            - echo $DEBUG_KEYSTORE_FILE_BASE64 | base64 -d &gt; keys/$DEBUG_KEYSTORE_FILE # decode base64 then use DEBUG_KEYSTORE_FILE as file name defined in repository variable
            - echo $KEYSTORE_FILE_BASE64 | base64 -d &gt; keys/$KEYSTORE_FILE # decode base64 then use KEYSTORE_FILE as file name defined in repository variable
            - echo $GOOGLE_PLAY_API_KEY_BASE64 | base64 -d &gt; keys/$GOOGLE_PLAY_API_KEY_FILE # decode base64 then use GOOGLE_PLAY_API_KEY_FILE as file name defined in repository variable
          artifacts:
            - keys/** # keep these artifacts for subsequent pipeline steps
  
  - step:
          name: Build &amp; Deploy (Internal)
          caches: # caching speed up subsequent execution https://support.atlassian.com/bitbucket-cloud/docs/cache-dependencies/
            - gradle
          script:
            # publish the aab file to the internal testing channel
            # the plugin publishes to the internal testing track by default
            - chmod +x gradlew
            - &quot;./gradlew
                         -PANDROID_BUILD_COMPILED_SDK_VERSION=$ANDROID_BUILD_COMPILED_SDK_VERSION
                         -PANDROID_BUILD_MIN_SDK_VERSION=$ANDROID_BUILD_MIN_SDK_VERSION
                         -PANDROID_BUILD_TARGET_SDK_VERSION=$ANDROID_BUILD_TARGET_SDK_VERSION
  
                         -PDEBUG_KEYSTORE_FILE=../keys/$DEBUG_KEYSTORE_FILE
                         -PDEBUG_KEYSTORE_PASSWORD=$DEBUG_PASSWORD
                         -PDEBUG_KEYSTORE_KEY_ALIAS=$DEBUG_KEY_ALIAS
                         -PDEBUG_KEYSTORE_KEY_PASSWORD=$DEBUG_KEY_PASSWORD
  
                         -PAPPNAME_KEYSTORE_FILE=../keys/$KEYSTORE_FILE
                         -PAPPNAME_KEYSTORE_PASSWORD=$KEYSTORE_PASSWORD
                         -PAPPNAME_KEY_ALIAS=$KEYSTORE_KEY_ALIAS
                         -PAPPNAME_KEY_PASSWORD=$KEY_PASSWORD
  
                         -PGOOGLE_PLAY_API_KEY=../keys/$GOOGLE_PLAY_API_KEY
  
                         -PBUILD_NUMBER=$BITBUCKET_BUILD_NUMBER
  
                          clean :app:publishReleaseBundle&quot;
          artifacts:
            - app/build/outputs/ # artifacts are files that are produced by a step https://support.atlassian.com/bitbucket-cloud/docs/use-artifacts-in-steps/
  </code></pre>
  <p>The problem is
  <code>-PDEBUG_KEYSTORE_FILE=../keys/$DEBUG_KEYSTORE_FILE</code> is somewhat being ignored and not working during build.</p>
  <pre><code>Build setup5s
  
  chmod +x gradlew&lt;1s
  
  ./gradlew -PANDROID_BUILD_COMPILED_SDK_VERSION=$ANDROID_BUILD_COMPILED_SDK_VERSION -PANDROID_BUILD_MIN_SDK_VERSION=$ANDROID_BUILD_MIN_SDK_VERSION -PANDROID_BUILD_TARGET_SDK_VERSION=$ANDROID_BUILD_TARGET_SDK_VERSION -PDEBUG_KEYSTORE_FILE=../keys/$DEBUG_KEYSTORE_FILE -PDEBUG_KEYSTORE_PASSWORD=$DEBUG_PASSWORD -PDEBUG_KEYSTORE_KEY_ALIAS=$DEBUG_KEY_ALIAS -PDEBUG_KEYSTORE_KEY_PASSWORD=$DEBUG_KEY_PASSWORD -PAPPNAME_KEYSTORE_FILE=../keys/$KEYSTORE_FILE -PAPPNAME_KEYSTORE_PASSWORD=$KEYSTORE_PASSWORD -PAPPNAME_KEY_ALIAS=$KEYSTORE_KEY_ALIAS -PAPPNAME_KEY_PASSWORD=$KEY_PASSWORD -PGOOGLE_PLAY_API_KEY=../keys/$GOOGLE_PLAY_API_KEY -PBUILD_NUMBER=$BITBUCKET_BUILD_NUMBER clean :app:publishFreeReleaseBundle39s
  
  + ./gradlew -PANDROID_BUILD_COMPILED_SDK_VERSION=$ANDROID_BUILD_COMPILED_SDK_VERSION -PANDROID_BUILD_MIN_SDK_VERSION=$ANDROID_BUILD_MIN_SDK_VERSION -PANDROID_BUILD_TARGET_SDK_VERSION=$ANDROID_BUILD_TARGET_SDK_VERSION
  -PDEBUG_KEYSTORE_FILE=../keys/$DEBUG_KEYSTORE_FILE -PDEBUG_KEYSTORE_PASSWORD=$DEBUG_PASSWORD -PDEBUG_KEYSTORE_KEY_ALIAS=$DEBUG_KEY_ALIAS -PDEBUG_KEYSTORE_KEY_PASSWORD=$DEBUG_KEY_PASSWORD
  -PAPPNAME_KEYSTORE_FILE=../keys/$KEYSTORE_FILE -PAPPNAME_KEYSTORE_PASSWORD=$KEYSTORE_PASSWORD -PAPPNAME_KEY_ALIAS=$KEYSTORE_KEY_ALIAS -PAPPNAME_KEY_PASSWORD=$KEY_PASSWORD
  -PGOOGLE_PLAY_API_KEY=../keys/$GOOGLE_PLAY_API_KEY
  -PBUILD_NUMBER=$BITBUCKET_BUILD_NUMBER
  clean :app:publishFreeReleaseBundle
  Downloading https://services.gradle.org/distributions/gradle-7.0-bin.zip
  ...........................................................................................................
  Unzipping /root/.gradle/wrapper/dists/gradle-7.0-bin/2p9ebqfz6ilrfozi676ogco7n/gradle-7.0-bin.zip to /root/.gradle/wrapper/dists/gradle-7.0-bin/2p9ebqfz6ilrfozi676ogco7n
  Set executable permissions for: /root/.gradle/wrapper/dists/gradle-7.0-bin/2p9ebqfz6ilrfozi676ogco7n/gradle-7.0/bin/gradle
  Welcome to Gradle 7.0!
  Here are the highlights of this release:
   - File system watching enabled by default
   - Support for running with and building Java 16 projects
   - Native support for Apple Silicon processors
   - Dependency catalog feature preview
  For more details see https://docs.gradle.org/7.0/release-notes.html
  Starting a Gradle Daemon (subsequent builds will be faster)
  FAILURE: Build failed with an exception.
  * Where:
  Build file '/opt/atlassian/pipelines/agent/build/app/build.gradle' line: 27
  * What went wrong:
  A problem occurred evaluating project ':app'.
  &gt; Could not get unknown property 'DEBUG_KEYSTORE_FILE' for SigningConfig_Decorated{name=debug, storeFile=/opt/android-sdk-linux/.android/debug.keystore, storePassword=android, keyAlias=AndroidDebugKey, keyPassword=android, storeType=pkcs12, v1SigningEnabled=true, v2SigningEnabled=true, enableV1Signing=null, enableV2Signing=null, enableV3Signing=null, enableV4Signing=null} of type com.android.build.gradle.internal.dsl.SigningConfig.
  * Try:
  Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
  * Get more help at https://help.gradle.org
  BUILD FAILED in 39s
  </code></pre>
  <p>However trying to test it out further I tried to remove <code>-PANDROID_BUILD_COMPILED_SDK_VERSION=$ANDROID_BUILD_COMPILED_SDK_VERSION</code> argument and the error is now on compileSdk</p>
  <pre><code>FAILURE: Build completed with 2 failures.
  1: Task failed with an exception.
  -----------
  * Where:
  Build file '/opt/atlassian/pipelines/agent/build/app/build.gradle' line: 13
  * What went wrong:
  A problem occurred evaluating project ':app'.
  &gt; Could not get unknown property 'ANDROID_BUILD_COMPILED_SDK_VERSION' for extension 'android' of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension.
  * Try:
  Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
  ==============================================================================
  2: Task failed with an exception.
  -----------
  * What went wrong:
  A problem occurred configuring project ':app'.
  &gt; compileSdkVersion is not specified. Please add it to build.gradle
  * Try:
  Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
  ==============================================================================
  Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
  Use '--warning-mode all' to show the individual deprecation warnings.
  See https://docs.gradle.org/7.0/userguide/command_line_interface.html#sec:command_line_warnings
  * Get more help at https://help.gradle.org
  BUILD FAILED in 39s
  </code></pre>
  <p>With this I assumed that the argument works fine but when it comes to signing it seems that my own signing config is being ignored.</p>
  <p>This is the app Gradle file looks like.</p>
  <pre><code>android {
      compileSdk Integer.parseInt(ANDROID_BUILD_COMPILED_SDK_VERSION)
  
      defaultConfig {
          applicationId &quot;com.app.name&quot;
          minSdk Integer.parseInt(ANDROID_BUILD_MIN_SDK_VERSION)
          targetSdk Integer.parseInt(ANDROID_BUILD_TARGET_SDK_VERSION)
          versionCode project.hasProperty('BUILD_NUMBER') ? project['BUILD_NUMBER'].toInteger() : 14
          versionName &quot;1.3.3&quot;
          vectorDrawables.useSupportLibrary = true
          testInstrumentationRunner &quot;androidx.test.runner.AndroidJUnitRunner&quot;
      }
  
      signingConfigs {
          debug {
              storeFile file(DEBUG_KEYSTORE_FILE)
              storePassword DEBUG_KEYSTORE_PASSWORD
              keyAlias DEBUG_KEYSTORE_KEY_ALIAS
              keyPassword DEBUG_KEYSTORE_KEY_PASSWORD
          }
          release {
              storeFile file(APPNAME_KEYSTORE_FILE)
              storePassword APPNAME_KEYSTORE_PASSWORD
              keyAlias APPNAME_KEYSTORE_KEY_ALIAS
              keyPassword APPNAME_KEYSTORE_KEY_PASSWORD
          }
      }
  
      buildTypes {
          debug {
              debuggable true
              minifyEnabled true
              shrinkResources true
              multiDexEnabled true
              proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  
              signingConfig signingConfigs.debug
          }
          release {
              debuggable false
              minifyEnabled true
              shrinkResources true
              multiDexEnabled true
              proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  
              signingConfig signingConfigs.release
          }
      }
  
      compileOptions {
          // Flag to enable support for the new language APIs
          coreLibraryDesugaringEnabled true
          // Sets Java compatibility to Java 8
          sourceCompatibility JavaVersion.VERSION_1_8
          targetCompatibility JavaVersion.VERSION_1_8
      }
  
      kotlinOptions {
          jvmTarget = &quot;1.8&quot;
      }
  
      lintOptions {
          disable &quot;MissingClass&quot;
      }
  
      buildFeatures {
          viewBinding true
      }
  }
  
  play {
      serviceAccountCredentials.set(file(GOOGLE_PLAY_API_KEY_FILE))
  }
  </code></pre>
  <p><strong>UPDATE:</strong>
  It seems like its not specific to debug signing but also with release I get
  <code>Could not get unknown property 'APPNAME_KEYSTORE_FILE'</code></p>
  <p><strong>Running it locally on Android Studio terminal works but in pipeline it doesn't work.</strong></p>
  <p>If the file path or location is the problem the error message should not <code>Could not get unknown property</code>.</p>