Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sample CircleCI Configuration For an Android App
#
# Build configuration for Circle CI
#
general:
artifacts:
- /home/ubuntu/your-app-name/app/build/outputs/apk/
machine:
environment:
ANDROID_HOME: /usr/local/android-sdk-linux
dependencies:
override:
- echo y | android update sdk --no-ui --all --filter tools,platform-tools,build-tools-19.1.0,android-19,extra-google-m2repository,extra-google-google_play_services,extra-android-support
- ANDROID_HOME=/usr/local/android-sdk-linux ./gradlew dependencies
test:
override:
- (./gradlew assemble):
timeout: 360
#
# Build configuration for Circle CI
#
general:
artifacts:
- /home/ubuntu/your-app-name/app/build/outputs/apk/
machine:
environment:
ANDROID_HOME: /usr/local/android-sdk-linux
dependencies:
override:
- echo y | android update sdk --no-ui --all --filter tools,platform-tools,build-tools-21.1.2,android-21,extra-google-m2repository,extra-google-google_play_services,extra-android-support
- ANDROID_HOME=/usr/local/android-sdk-linux ./gradlew dependencies
test:
override:
- (./gradlew assemble):
timeout: 360
@pawin

This comment has been minimized.

Show comment
Hide comment
@pawin

pawin Aug 30, 2016

Thank you! I finally be able to run my tests on CircleCI, however, I wondering that do we have to update android sdk every time?
- echo y | android update sdk --no-ui --all --filter tools,platform-tools,build-tools-21.1.2,android-21,extra-google-m2repository,extra-google-google_play_services,extra-android-support

pawin commented Aug 30, 2016

Thank you! I finally be able to run my tests on CircleCI, however, I wondering that do we have to update android sdk every time?
- echo y | android update sdk --no-ui --all --filter tools,platform-tools,build-tools-21.1.2,android-21,extra-google-m2repository,extra-google-google_play_services,extra-android-support

@yuripourre

This comment has been minimized.

Show comment
Hide comment
@yuripourre

yuripourre Sep 2, 2016

Thank you, it works!

yuripourre commented Sep 2, 2016

Thank you, it works!

@wching

This comment has been minimized.

Show comment
Hide comment
@wching

wching Sep 19, 2016

If you get this error on your build:

> Buildtools 24.0.2 requires Java 1.8 or above. Current JDK version is 1.7.

just add:

java:
    version: oraclejdk8

under the machine block.

It will look like the following:

machine:
    java:
        version: oraclejdk8
    environment:
        ANDROID_HOME: /usr/local/android-sdk-linux

Took the info from here: https://discuss.circleci.com/t/using-jdk-8-in-android/2255 (in case you were wondering).

Thanks Donn for sharing the sample circle.yml file! 👍

wching commented Sep 19, 2016

If you get this error on your build:

> Buildtools 24.0.2 requires Java 1.8 or above. Current JDK version is 1.7.

just add:

java:
    version: oraclejdk8

under the machine block.

It will look like the following:

machine:
    java:
        version: oraclejdk8
    environment:
        ANDROID_HOME: /usr/local/android-sdk-linux

Took the info from here: https://discuss.circleci.com/t/using-jdk-8-in-android/2255 (in case you were wondering).

Thanks Donn for sharing the sample circle.yml file! 👍

@derohimat

This comment has been minimized.

Show comment
Hide comment
@derohimat

derohimat Oct 25, 2016

I always failed with this issue

Output:
bash: line 1: ./gradlew: Permission denied

ANDROID_HOME=/usr/local/android-sdk-linux ./gradlew dependencies returned exit code 126

Action failed: ANDROID_HOME=/usr/local/android-sdk-linux ./gradlew dependencies

derohimat commented Oct 25, 2016

I always failed with this issue

Output:
bash: line 1: ./gradlew: Permission denied

ANDROID_HOME=/usr/local/android-sdk-linux ./gradlew dependencies returned exit code 126

Action failed: ANDROID_HOME=/usr/local/android-sdk-linux ./gradlew dependencies

@IlyaEremin

This comment has been minimized.

Show comment
Hide comment
@IlyaEremin

IlyaEremin Nov 15, 2016

@derohimat add following in your circle.yml:

dependencies:
  pre:
    - chmod +x gradlew

IlyaEremin commented Nov 15, 2016

@derohimat add following in your circle.yml:

dependencies:
  pre:
    - chmod +x gradlew
@aimanbaharum

This comment has been minimized.

Show comment
Hide comment
@aimanbaharum

aimanbaharum Nov 21, 2016

Very new at this. I got this error after I put circle.yml (24) into my repo:

modifiers to 'gradlew assemble)' must be a map

Action failed: Configure the build

Any idea why this is happening?

Never mind, there was a typo

aimanbaharum commented Nov 21, 2016

Very new at this. I got this error after I put circle.yml (24) into my repo:

modifiers to 'gradlew assemble)' must be a map

Action failed: Configure the build

Any idea why this is happening?

Never mind, there was a typo

@bolorundurowb

This comment has been minimized.

Show comment
Hide comment
@bolorundurowb

bolorundurowb Dec 23, 2016

I have this

dependencies:
    override:
        - echo "y" | android update sdk --no-ui --all --filter tools,platform-tools,build-tools-25.0.1,android-25,extra-google-m2repository,extra-google-google_play_services,extra-android-support
        - chmod +x gradlew
        - ANDROID_HOME=/usr/local/android-sdk-linux ./gradlew dependencies

and I get the following error

A problem occurred configuring project ':android-lib'.
> You have not accepted the license agreements of the following SDK components:
  [Android Support Repository].
  Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
  Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html

What am I missing?

bolorundurowb commented Dec 23, 2016

I have this

dependencies:
    override:
        - echo "y" | android update sdk --no-ui --all --filter tools,platform-tools,build-tools-25.0.1,android-25,extra-google-m2repository,extra-google-google_play_services,extra-android-support
        - chmod +x gradlew
        - ANDROID_HOME=/usr/local/android-sdk-linux ./gradlew dependencies

and I get the following error

A problem occurred configuring project ':android-lib'.
> You have not accepted the license agreements of the following SDK components:
  [Android Support Repository].
  Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
  Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html

What am I missing?

@mmartin101

This comment has been minimized.

Show comment
Hide comment
@mmartin101

mmartin101 Jan 30, 2017

@bolorundurowb there are different licenses that need to be accepted so you need to group your packages according to their license.

dependencies:
  pre:
    - echo y | android update sdk --no-ui --all --filter "platform-tools, tools"
    - echo y | android update sdk --no-ui --all --filter "android-24, build-tools-25.0.2"
    - echo y | android update sdk --no-ui --all --filter "extra-android-m2repository"
    - echo y | android update sdk --no-ui --all --filter "extra-android-support"

I also noticed that you have echo "y" try removing the quotes surrounding y

mmartin101 commented Jan 30, 2017

@bolorundurowb there are different licenses that need to be accepted so you need to group your packages according to their license.

dependencies:
  pre:
    - echo y | android update sdk --no-ui --all --filter "platform-tools, tools"
    - echo y | android update sdk --no-ui --all --filter "android-24, build-tools-25.0.2"
    - echo y | android update sdk --no-ui --all --filter "extra-android-m2repository"
    - echo y | android update sdk --no-ui --all --filter "extra-android-support"

I also noticed that you have echo "y" try removing the quotes surrounding y

@arj060892

This comment has been minimized.

Show comment
Hide comment
@arj060892

arj060892 Oct 3, 2017

hi ,i'm new to CircleCi , is their any way to output the .apk as artifact .I have tried the following line in .yml file
-store_artifacts:
path:app/build/output/apk
destination: apks/

and the output is : No artifact file found at location

arj060892 commented Oct 3, 2017

hi ,i'm new to CircleCi , is their any way to output the .apk as artifact .I have tried the following line in .yml file
-store_artifacts:
path:app/build/output/apk
destination: apks/

and the output is : No artifact file found at location

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment