Sonarcloud pipeline for mobile app project keeps failing

Template for a good new topic, formatted with Markdown:

  • ALM used: BitBucket
  • CI system used BitBucket Cloud
  • Languages of the repository: Kotlin
  • Error observed (wrap logs/code around with triple quotes ``` for proper formatting)
Please wait while Kotlin/Native compiler 1.8.10 is being installed.
Download (180.45 MB)
Download finished, took 2 s 332 ms
Unpack Kotlin/Native compiler to /root/.konan/kotlin-native-prebuilt-linux-x86_64-1.8.10
Unpack Kotlin/Native compiler to /root/.konan/kotlin-native-prebuilt-linux-x86_64-1.8.10 finished, took 3 s 415 ms
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':androidApp:compileDebugJavaWithJavac'.
> Could not determine the dependencies of null.
   > SDK location not found. Define a valid SDK location with an ANDROID_HOME environment variable or by setting the sdk.dir path in your project's local properties file at '/opt/atlassian/pipelines/agent/build/'.

Trying to add a pipeline to my mobile app code to run sonarcloud on it and the pipeline keeps failing. I’ve copied the pipeline code directly from Sonarcloud during setup, but it doesn’t work
The yaml file is as follows

image: openjdk:11

  depth: full              # SonarCloud scanner needs the full history to assign issues properly

    sonar: ~/.sonar/cache  # Caching SonarCloud artifacts will speed up your build
    - step: &build-test-sonarcloud
        name: Build, test and analyze on SonarCloud
          - gradle
          - sonar
          - ./gradlew build sonarqube
          - build/libs/**

pipelines:                 # More info here:
      - step: *build-test-sonarcloud
      - step: *build-test-sonarcloud

Hey there.

It seems like this is your issue.

Did you have a working build in Bitbucket Pipelines before trying to add SonarCloud analysis? You probably need a base image more tailored for Android app development (with the Android SDK installed and environment variables configured).