jangrewe / gitlab-ci-android

GitLab CI image for building Android apps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Could not find ANDROID_SDK_ROOT

javaherisaber opened this issue · comments

There is an error in runner console:

SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file

I tried to download command line tool and set sdk path manually
but it didn't work also

I'm not sure what you're doing to get this error message, but if used properly it definitely works as expected.

Just to confirm that ANDROID_SDK_ROOT is indeed defined by default:

$ docker run --rm jangrewe/gitlab-ci-android:30 env | grep ANDROID_SDK_ROOT
ANDROID_SDK_ROOT=/sdk

Maybe share your script so i can have a look what's wrong there?

Here is the script:

image: jangrewe/gitlab-ci-android

before_script:
  - export GRADLE_USER_HOME=$(pwd)/.gradle
  - chmod +x ./gradlew

# Make Project
assembleDebug:
  interruptible: true
  stage: build
  tags: [master]
  script:
    - ./gradlew assembleDebug
  artifacts:
    paths:
      - app/build/outputs/

# Run all tests, if any fails, interrupt the pipeline(fail it)
debugTests:
  interruptible: true
  stage: test
  tags: [master]
  script:
    - ./gradlew -Pci --console=plain :app:testDebug

That looks pretty standard and should work just fine - i'd just pin the image tag, e.g. 30, to prevent unexpected issues with the SDK version.

Can you share the full job log, so i can see where the error actually happens?

Full log of failed job:

Running with gitlab-runner 13.10.0 (54944146)
  on Shared runner for gitlab PFSpu-wr
Preparing the "shell" executor
Using Shell executor...
Preparing environment
Running on stage...
Getting source from Git repository
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /home/gitlab-runner/builds/PFSpu-wr/0/m.javaheri/testcicd/.git/
Checking out 0aa74ed3 as master...
Removing .gradle/
Skipping Git submodules setup
Executing "step_script" stage of the job script
$ export GRADLE_USER_HOME=$(pwd)/.gradle
$ chmod +x ./gradlew
$ ./gradlew assembleDebug
Downloading https://services.gradle.org/distributions/gradle-6.5-bin.zip
.................................................................................................
Unzipping /home/gitlab-runner/builds/PFSpu-wr/0/m.javaheri/testcicd/.gradle/wrapper/dists/gradle-6.5-bin/6nifqtx7604sqp1q6g8wikw7p/gradle-6.5-bin.zip to /home/gitlab-runner/builds/PFSpu-wr/0/m.javaheri/testcicd/.gradle/wrapper/dists/gradle-6.5-bin/6nifqtx7604sqp1q6g8wikw7p
Set executable permissions for: /home/gitlab-runner/builds/PFSpu-wr/0/m.javaheri/testcicd/.gradle/wrapper/dists/gradle-6.5-bin/6nifqtx7604sqp1q6g8wikw7p/gradle-6.5/bin/gradle
Welcome to Gradle 6.5!
Here are the highlights of this release:
 - Experimental file-system watching
 - Improved version ordering
 - New samples
For more details see https://docs.gradle.org/6.5/release-notes.html
Starting a Gradle Daemon, 1 stopped Daemon could not be reused, use --status for details
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/home/gitlab-runner/builds/PFSpu-wr/0/m.javaheri/testcicd/local.properties'.
* 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
BUILD FAILED in 5m 24s
Cleaning up file based variables
ERROR: Job failed: exit status 1

Btw i'm using compile sdk version 30 and build tools 30.0.3 in my codebase

commented

Hey @javaherisaber,
i had the same error today.. See line 4 of your log "Using Shell executor..."
=> You are not using a docker executor, so the "image: xxx" in the .gitlab-ci.yml will be ignored.

Issue can be probably closed?

Same issue here, I get the same error.

Log:

Running with gitlab-runner 13.12.0 (7a6612da)
  on android nKp6qyGf
Preparing the "shell" executor
Using Shell executor...
Preparing environment
Running on mail.nextjourney.ph...
Getting source from Git repository
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /home/gitlab-runner/builds/nKp6qyGf/0/saeid/feedopedia-android/.git/
Checking out def31164 as develop...
Removing .gradle/
Removing hs_err_pid2058.log
Skipping Git submodules setup
Restoring cache
Checking cache for 16...
Runtime platform                                    arch=amd64 os=linux pid=6541 revision=7a6612da version=13.12.0
No URL provided, cache will not be downloaded from shared cache server. Instead a local version of cache will be extracted. 
Successfully extracted cache
Executing "step_script" stage of the job script
$ export GRADLE_USER_HOME=$(pwd)/.gradle
$ chmod +x ./gradlew
$ ./gradlew assembleDebug
Downloading https://services.gradle.org/distributions/gradle-7.0.2-bin.zip
..........................................................................................................
Unzipping /home/gitlab-runner/builds/nKp6qyGf/0/saeid/feedopedia-android/.gradle/wrapper/dists/gradle-7.0.2-bin/857tjihv64xamwrf0h14cai3r/gradle-7.0.2-bin.zip to /home/gitlab-runner/builds/nKp6qyGf/0/saeid/feedopedia-android/.gradle/wrapper/dists/gradle-7.0.2-bin/857tjihv64xamwrf0h14cai3r
Set executable permissions for: /home/gitlab-runner/builds/nKp6qyGf/0/saeid/feedopedia-android/.gradle/wrapper/dists/gradle-7.0.2-bin/857tjihv64xamwrf0h14cai3r/gradle-7.0.2/bin/gradle

Welcome to Gradle 7.0.2!

Here are the highlights of this release:
 - File system watching enabled by default
 - Support for running with and building Java 16 projects
 - Native support for Apple Silicon processors
 - Dependency catalog feature preview

For more details see https://docs.gradle.org/7.0.2/release-notes.html

To honour the JVM settings for this build a single-use Daemon process will be forked. See https://docs.gradle.org/7.0.2/userguide/gradle_daemon.html#sec:disabling_the_daemon.
Daemon will be stopped at the end of the build 

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/home/gitlab-runner/builds/nKp6qyGf/0/saeid/feedopedia-android/local.properties'.

* 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

BUILD FAILED in 1m 19s
Cleaning up file based variables
ERROR: Job failed: exit status 1

@moeindev please provide a job log. i guess the comment above yours should be a good pointer for a potential problem.

@jangrewe updated my comment

Thanks, and it's exactly the same issue:

Preparing the "shell" executor

This is a Docker image. It needs to be ran with the Docker executor.