SonarCloud PR Analysis/Decoration on BitBucket Cloud not working

Private BitBucket Cloud repo for Android project.
Analysis ran in BitBucket Cloud Pipeline.

I am having an issue with the SonarCloud PR Analysis, which in turn seems to be affecting the SonarCloud PR Decoration.

It seems like SonarCloud is not able to see any other branches than the ‘main’ branch of the Repo.
Only merges into ‘main’ branch gets analysed and tracked in SonarCloud.
PRs into ‘main’ or any other branches run the BitBucket Pipeline, that runs SonarCloud Gradle task, but no info is made available in either SonarCloud portal or BitBucket PRs.
The SonarCloud section of the PR, ‘Code Quality’ only displays the text “Not analyzed on SonarCloud yet”.

Below is the bitbucket-pipelines.yml file that runs the analysis.

image: bitriseio/docker-android

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

definitions:
  caches:
    sonar: ~/.sonar/cache  # Caching SonarCloud artifacts will speed up your build
  steps:
    - step: &build-test-sonarcloud
        name: Build, test and analyze on SonarCloud
        caches:
          - gradle
          - sonar
        script:
          - sudo update-alternatives --set javac /usr/lib/jvm/java-11-openjdk-amd64/bin/javac
          - sudo update-alternatives --set java /usr/lib/jvm/java-11-openjdk-amd64/bin/java
          - export JAVA_HOME='/usr/lib/jvm/java-11-openjdk-amd64'
          - ./gradlew build sonarqube -x lint
        artifacts:
          - build/libs/**

pipelines:                 # More info here: https://confluence.atlassian.com/bitbucket/configure-bitbucket-pipelines-yml-792298910.html
  branches:
    master:
      - step: *build-test-sonarcloud
  pull-requests:
    '**':
      - step: *build-test-sonarcloud

Welcome to the community, and sorry for the delayed answer.

When your build pipeline is executed on a pull request, does the gradle command (which executes the code analysis) complete successfully? Can you confirm in the log output of the pipeline run? If you add --info to the gradle command, then the end of the output should look something like this:

ANALYSIS SUCCESSFUL, you can find the results at: https://sonarcloud.io/dashboard?id=foo&pullRequest=123
Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
More about the report processing at https://sonarcloud.io/api/ce/task?id=bar

Notice the &pullRequest= at the end of the first link, this is a good sign of a correctly configured pull request analysis.

If the main branch is correctly analyzed, I see no reason for the pull request analysis to not work, however, your description suggests that the pull request analyses in fact have not reached SonarCloud. The scanner output (of the gradle command) should help us understand what happened.