version: 2
jobs:
  build:
    docker:
      - image: stefma-docker-hub.bintray.io/android-build-env:0.2-alpha

    steps:
      - checkout

      # Try to restore cache (see ho to save cache below 👇)
      - restore_cache:
          key: gradle-cache-v0-{{ checksum "build.gradle.kts" }}-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}

      - run: echo "sdk.dir=$HOME/android-sdk" >> local.properties
      - run: ./gradlew test --no-daemon

       # Save the gradle folder for caching
      - save_cache:
          paths:
            - ~/.gradle
          key: gradle-cache-v0-{{ checksum "build.gradle.kts" }}-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}
version: 2
jobs:
  build:
    machine:
      image: circleci/classic:latest

    environment:
      # Customize the JVM maximum heap limit
      # Needs to be updated along with gradle jvmargs 👇
      _JAVA_OPTIONS: "-Xmx2g"

    steps:
      - checkout

      # Set the JVM heap size to gradle as well
      - run: echo "org.gradle.jvmargs=-Xmx2G" >> gradle.properties

      # Download/Install Android SDK for testing
      - run: wget -q https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip
      - run: unzip -q sdk-tools-linux-3859397.zip
      - run: mkdir $HOME/android-sdk
      - run: mv tools $HOME/android-sdk/tools
      - run: mkdir $HOME/android-sdk/licenses
      - run: echo -e "\nd56f5187479451eabf01fb78af6dfcb131a6481e" > "$HOME/android-sdk/licenses/android-sdk-license"
      - run: echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$HOME/android-sdk/licenses/android-sdk-preview-license"

      # Try to restore cache (see ho to save cache below 👇)
      - restore_cache:
          key: gradle-cache-v0-{{ checksum "build.gradle.kts" }}-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}

      - run:
          environment:
              ANDROID_HOME: "/home/circleci/android-sdk" # TODO: Try to don't hardcode me and use $HOME env variable
          command: ./gradlew test --no-daemon

      - save_cache:
          paths:
            - ~/.gradle
          key: gradle-cache-v0-{{ checksum "build.gradle.kts" }}-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}
Switch from Docker to machine
Switch from Docker to machine
