Can not find a class that lies in the repo. Rebuild helps

I am not sure if it is a CircleCI bug, however, we run into a problem when every second build or so fails because it can’t find some base classes that are definitely there. Pressing a “rebuild” hepls, sometimes, after several retries. I’ve run the same Gradle command in terminal several time and it all worked well.


Here is the error message:

 Processed 10 entities in 88ms
    Note: [ObjectBox] Starting ObjectBox processor (debug: false)
    Note: [1] Wrote GeneratedAppGlideModule with: []
    /home/circleci/src/app/src/main/java/com/vyng/android/home/channel/listupdated/ChannelListContract.java:45: error: cannot find symbol
      interface Presenter extends BasePresenterWithPublisher<View, ChannelListEvents> {
                                  ^
      symbol:   class BasePresenterWithPublisher
      location: interface ChannelListContract
    /home/circleci/src/app/src/main/java/com/vyng/android/home/channel/listupdated/ChannelListContract.java:22: error: cannot find symbol
      interface View extends BaseView<Presenter> {
                             ^
      symbol:   class BaseView
      location: interface ChannelListContract
    2 errors
    :app:compileQaReleaseJavaWithJavac FAILED

    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':app:compileQaReleaseJavaWithJavac'.
    > Compilation failed; see the compiler error output for details.

    * 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

    Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
    See https://docs.gradle.org/4.6/userguide/command_line_interface.html#sec:command_line_warnings

    BUILD FAILED in 21s
    80 actionable tasks: 76 executed, 4 from cache
    Exited with code 1

And here is the correct ouput (the end of it, actually):

Processed 10 entities in 83ms
Note: [ObjectBox] Starting ObjectBox processor (debug: false)
Note: [1] Wrote GeneratedAppGlideModule with: []
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
:app:javaPreCompileQaReleaseUnitTest
:app:compileQaReleaseUnitTestJavaWithJavacNote: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

:app:testQaReleaseUnitTest
Calling mockable JAR artifact transform to create file: /home/circleci/.gradle/caches/transforms-1/files-1.1/android.jar/7ebb58e924a910c356eb5793fb451ae9/android.jar with input /opt/android/sdk/platforms/android-28/android.jar
Picked up _JAVA_OPTIONS: -Xmx2048m -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
See https://docs.gradle.org/4.6/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 28s
83 actionable tasks: 78 executed, 5 from cache

That’s our config:
version: 2.1

references:
  ## Workspaces
  workspace: &workspace
    ~/src

  ## Docker image configurations
  android_config: &android_config
    working_directory: *workspace
    docker:
      - image: circleci/android:api-27-alpha
    environment:
      TERM: dumb
      _JAVA_OPTIONS: "-Xmx2048m -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap"
      GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m"'

  ## Cache
  gradle_key: &gradle_key
    jars-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}

  restore_gradle_cache: &restore_gradle_cache
    restore_cache:
      key: *gradle_key

  save_gradle_cache: &save_gradle_cache
    save_cache:
      key: *gradle_key
      paths:
        - ~/.gradle

  ## Dependencies
  android_dependencies: &android_dependencies
    run:
      name: Download Android Dependencies
      command: ./gradlew androidDependencies

commands:
  git_setup:
    description: "Commands needed to sync and update git and it's submodules"
    steps:
      - run:
          name: Git Submodule Sync
          command: git submodule sync
      - run:
          name: Git Submodule Update
          command: git submodule update --init

jobs:
  ## Run unit tests
  unit_tests:
    <<: *android_config

    steps:
      - checkout
      - git_setup
      - *android_dependencies
      - run:
          name: Run Qa Unit tests
          command: ./gradlew testQaReleaseUnitTest
      - store_artifacts:
          path: app/build/reports
          destination: vyng-android

  ## Deploy to Crashlytics Beta
  deploy_beta:
    <<: *android_config

    steps:
      - checkout
      - git_setup
      - *restore_gradle_cache
      - *android_dependencies
      - *save_gradle_cache
      - run:
          name: QA build
          command: ./gradlew clean assembleQaRelease
      - store_artifacts:
          name: Upload apk
          path: app/build/outputs/apk/
          destination: apks/
      - deploy:
          name: "Deploy to Fabric"
          command: ./gradlew crashlyticsUploadDistributionQaRelease

  deploy_release_candidate:
    <<: *android_config

    steps:
      - checkout
      - git_setup
      - *restore_gradle_cache
      - *android_dependencies
      - *save_gradle_cache
      - add_ssh_keys
      - run:
          name: Release Candidate build
          command: ./gradlew clean assembleProductionRelease
      - store_artifacts:
          name: Upload apk
          path: app/build/outputs/apk/
          destination: apks/
      - deploy:
          name: "Deploy to Fabric"
          command: ./gradlew crashlyticsUploadDistributionProductionRelease

workflows:
  test_and_deploy:
    jobs:
      - unit_tests
##      - deploy_beta:
##          requires:
##            - unit_tests
##          filters:
##            tags:
##              only: /qa-.*/

That’s very odd. I can’t think of any kind of bug that CircleCI could have that would result in this issue. The thing to understand about CI is that it is broadly just a virtual machine or a container where you get some runtime to run an operation for a limited period of time. That’s it, really - so bugs are either with the base OS (unlikely), the CI scheduler (not applicable here), the CI UI (not applicable here) or your set-up (most likely).

Is there any way you can intercept the compile error and get it to print the include paths to the console? Or maybe list the contents of those include paths?

I’d consider fixing this if you can - maybe upgrading Gradle would help.

Sound logical. The only question was if it might be bound to some issues with caching mechanisms. Ok, we will try to find the issue, thank you.

Is there any solution for this? It seems like I face the same issue.
gradlew test failed multiple times at point:

Task :app:test
Calling mockable JAR artifact transform to create file: /home/circleci/.gradle/caches/transforms-1/files-1.1/android.jar/501ba7adc2e2ed6d9aa717a142281512/android.jar with input /opt/android/sdk/platforms/android-28/android.jar

About 3/10 times it succeeds if hitting rerun workflow button :expressionless:

Also have the save issue when do ./gradlew assemblePlayProductionRelease:

Task :app:lintVitalPlayProductionRelease
Calling mockable JAR artifact transform to create file: /home/circleci/.gradle/caches/transforms-2/files-2.1/a778aa1e0feafa263a5de796330a3248/android.jar with input /opt/android/sdk/platforms/android-28/android.jar

Other commands ./gradlew testPlayDevelopmentDebugUnitTest, ./gradlew lintPlayProductionRelease work without errors.
rerun workflow helps very seldom.

On local computer build works fine.

Config:

version: 2

references:

  cache_key: &cache_key
    key: cache-v9-{{ checksum "build.gradle" }}-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}-{{ checksum  "app/build.gradle" }}-{{ checksum  "modules/ImageViewPager/build.gradle" }}-{{ checksum  "modules/CCP/build.gradle" }}-{{ checksum  "modules/FastScroll/build.gradle" }}

  restore_cache: &restore_cache
    restore_cache:
      <<: *cache_key
  save_cache: &save_cache
    save_cache:
      <<: *cache_key
      paths:
        - ~/.gradle

  workspace: &workspace
    ~/workspace

  android_config: &android_config
    working_directory: *workspace
    docker:
      - image: circleci/android:api-29
    environment:
      JVM_OPTS: "-Xmx3200m"
      GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx3200m"'


  download_dependencies: &download_dependencies
    run:
      name: Download dependencies
      command: ./gradlew androidDependencies

  filter_branches: &filter_branches
    filters:
      branches:
        only:
          - develop
          - stage
          - master
#          - circle2_migration



jobs:

  test_unit:
    <<: *android_config
    steps:
      - checkout
      - *restore_cache
      - *download_dependencies
      - *save_cache

      - run:
          name: Unit tests
          command: |
            ./gradlew testPlayDevelopmentDebugUnitTest -PdisablePreDex
      - store_artifacts:
          path: app/build/reports/
          destination: /unit tests/
      - store_test_results:
          path: app/build/test-results/
          destination: /test-results/

  lint:
    <<: *android_config
    steps:
      - checkout
      - *restore_cache
      - *download_dependencies
      - *save_cache

      - run:
          name: Lint check
          command: |
            if [ $CIRCLE_BRANCH = 'develop' ]; then
              ./gradlew lintPlayDevelopmentDebug -PdisablePreDex
            elif [ $CIRCLE_BRANCH = 'stage' ]; then
              ./gradlew lintPlayStagingRelease -PdisablePreDex
            elif [ $CIRCLE_BRANCH = 'master' ]; then
              ./gradlew lintPlayProductionRelease -PdisablePreDex
            fi
      - store_artifacts:
          path: app/build/reports/
          destination: /lint/

  build:
    <<: *android_config
    steps:
      - checkout
      - *restore_cache
      - *download_dependencies
      - *save_cache
      - run:
          name: Build
          command: |
            if [ $CIRCLE_BRANCH = 'develop' ]; then
              cp ./certificates/debug.keystore ~/.android/debug.keystore
              ./gradlew assemblePlayDevelopmentDebug -PdisablePreDex
            elif [ $CIRCLE_BRANCH = 'stage' ]; then
              ./gradlew assemblePlayStagingRelease -PdisablePreDex
            elif [ $CIRCLE_BRANCH = 'master' ]; then
              ./gradlew assemblePlayProductionRelease -PdisablePreDex
            fi
      - persist_to_workspace:
          root: *workspace
          paths:
            - app/build/

  deploy:
    <<: *android_config
    steps:
      - checkout
      - attach_workspace:
          at: *workspace
      - *restore_cache
      - *download_dependencies
      - store_artifacts:
          path: app/build/outputs/apk/
          destination: /apk/
      - run:
          name: Deploy to Fabric Beta
          command: |
            if [ $CIRCLE_BRANCH = 'develop' ]; then
              cp ./certificates/debug.keystore ~/.android/debug.keystore
              ./gradlew -PdisablePreDex crashlyticsUploadDistributionPlayDevelopmentDebug
            elif [ $CIRCLE_BRANCH = 'stage' ]; then
              ./gradlew -PdisablePreDex crashlyticsUploadDistributionPlayStagingRelease
            elif [ $CIRCLE_BRANCH = 'master' ]; then
              ./gradlew -PdisablePreDex crashlyticsUploadDistributionPlayProductionRelease
            fi

workflows:
  version: 2
  workflow:
    jobs:
      - test_unit:
          <<: *filter_branches
      - lint:
          <<: *filter_branches
      - build:
          <<: *filter_branches
      - deploy:
          <<: *filter_branches
          requires:
            - test_unit
            - lint
            - build