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


#1

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-.*/

#2

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?


#3

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


#4

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.


#5

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: