Fastlane integration has ERROR: JAVA_HOME

android
java
fastlane
cci-20

#1

Hi, I am trying to migrate my circleci.yml to the version 2.0. The build job is working but when I am trying to deploy, circleci send an error saying:

15:33:00]: Exit status of command ‘/home/circleci/code/gradlew doBuildNumberIncrement -p .’ was 1 instead of 0.

ERROR: JAVA_HOME is not set and no ‘java’ command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

version: 2
general:
  artifacts:
    - "app/build/reports/androidTests/connected"

jobs:
  build:
    working_directory: ~/code
    docker:
        - image: circleci/android:api-25-alpha
    environment:
        JVM_OPTS: -Xmx3200m
    steps:
        - checkout
        - restore_cache:
            key: jars-{{ checksum "build.gradle" }}-{{ checksum  "app/build.gradle" }}
        - run:
            name: Download Dependencies
            command: ./gradlew androidDependencies
        - save_cache:
            paths:
              - ~/.gradle
            key: jars-{{ checksum "build.gradle" }}-{{ checksum  "app/build.gradle" }}
        - run:
            name: Run Tests
            command: ./gradlew lint test
        - store_artifacts:
              path: app/build/reports
              destination: reports
        - store_test_results:
              path: app/build/test-results
  deploy:
    working_directory: ~/code
    docker:
        - image: circleci/ruby:2.4.1-node
        - image: circleci/openjdk:8-jdk-browsers
    steps:
        - checkout

        # Restore bundle cache
        - type: cache-restore
          key: pt-{{ checksum "Gemfile.lock" }}
        - run:
            name: Install dependencies
            command: |
              sudo apt-get install libicu-dev
              gem install bundler
              bundle install

        # Store bundle cache
        - type: cache-save
          key: pt-{{ checksum "Gemfile.lock" }}
          paths:
              - vendor/bundle

        - run:
            name: Update fastlane
            command: bundle update fastlane

        - run:
            name: Deploy to Crashlytics
            command: bundle exec fastlane beta


workflows:
  version: 2
  build_test_deploy_beta:
    jobs:
      - deploy

Could you please help me to fix this? I spent all the day trying to solve it but any progress :frowning:
Thanks!


#2

Hi!

I hope this script can help you with Fastlane integration I’m not CI expert but I do this:

I start with android 26 docker image then Install ruby and fastlane

###install gems
sudo apt-get install ruby-full build-essential

###install fastlane
sudo gem install fastlane --no-rdoc --no-ri

And you are ready to deploy!


#3

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.