Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to setup Pipelines for an Android app

Deleted user Oct 13, 2016

Is it possible to setup Pipelines to build an Android app? At the moment, I'm getting the following:

location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

 

I'm using the default config file at the moment as I can't find anything regarding Android builds.

# This is a sample build configuration for Gradle.
# Check our guides at https://confluence.atlassian.com/x/VYk8Lw for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: java:8

pipelines:
  default:
    - step:
        script: # Modify the commands below to build your repository.
          - android update sdk --filter "build-tools-23.0.3" --no-ui -a   
          - ./gradlew build

 

Thanks.

6 answers

1 accepted

Download and run on latest sdk with sdkmanager.

# This is a sample build configuration for Java (Gradle).
# Check our guides at https://confluence.atlassian.com/x/zd-5Mw for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: java:8

pipelines:
default:
- step:
caches:
- gradle
- android-sdk

script:
# Download and unzip android sdk
- wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip
- unzip -o -qq android-sdk.zip -d android-sdk

# Define Android Home and add PATHs
- export ANDROID_HOME="/opt/atlassian/pipelines/agent/build/android-sdk"
- export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH"

# Download packages.
- yes | sdkmanager "platform-tools"
- yes | sdkmanager "platforms;android-27"
- yes | sdkmanager "build-tools;27.0.3"
- yes | sdkmanager "extras;android;m2repository"
- yes | sdkmanager "extras;google;m2repository"
- yes | sdkmanager "extras;google;instantapps"
- yes | sdkmanager --licenses

# Build apk
- chmod a+x ./gradlew
- ./gradlew assembleDebug

definitions:
caches:
android-sdk: android-sdk

Works a treat the first time but subsequent builds results in the following failure:

Screen Shot 2018-01-20 at 15.47.35.png

Cache "gradle": Downloading
Cache "gradle": Extracting
Cache "gradle": Extracted
Cache "android-sdk": Downloading
Cache "android-sdk": Extracting
Cache "android-sdk": Extracted
+ wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip

+ unzip -qq android-sdk.zip -d android-sdk
replace android-sdk/tools/bin/lint? [y]es, [n]o, [A]ll, [N]one, [r]ename: NULL
(EOF or read error, treating as "[N]one" ...)

 

Try add the option -o to the unzip command below:

- unzip -o -qq android-sdk.zip -d android-sdk

See the basic unzip command options below:

-f freshen existing files, create none
-n never overwrite existing files
-q quiet mode (-qq => quieter)
-o overwrite files WITHOUT prompting

The -qq is for quieter mode and the -o will overwrite files without prompting.

Hope this helps.

Deleted user Jan 23, 2018

Doh! Sorry and thanks @Simon Barber

Thanks @Simon Barber updated answer.

The android-sdk was not being added to the cache. 

I had to update definition to: 

definitions:
caches:
android-sdk: /opt/atlassian/pipelines/agent/build/android-sdk

* Cache took time to update, If i wait it might have started working with just android-sdk

copy yml, change to api 28, error

The SDK directory '/opt/atlassian/pipelines/agent/build/D:\Android\sdk' does not exist.
Like sanosarvar likes this

I've found an article about Android + Pipelines integration: https://medium.com/rocknnull/setup-android-continuous-integration-ci-for-bitbucket-in-1-minute-9b72a4f1d745.

The `bitbucket-pipelines.yml` file looks pretty simple as a result of using Docker image `mingc/android-build-box`.

 

image: mingc/android-build-box:latest

pipelines:
    default:
        - step:
            caches:
                - gradle
            script:
                - chmod +x gradlew
                - ./gradlew assembleDebug

 

But there is no APK present in ./gradlew or any of the folders in repo or artifacts list. Actually i want the downloadable APK in Artifacts list.

Hi, there is no android sdk preinstalled on Docker image java:8. So you can download and install the sdk manually. The following steps works with my pipeline.

But i think a better and much faster way is to use an prepared docker image like this: https://hub.docker.com/r/guptasanchit90/android-gradle/

Hope this helps:

image: java:8
pipelines:
  default:
    - step:
        script:
          # Download and unzip android sdk
          - wget https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz
          - tar zxvf android-sdk*.tgz
          # Define android Home and add PATHs (After that you can run "android")
          - export ANDROID_HOME="/opt/atlassian/pipelines/agent/build/android-sdk-linux"
          - export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH"
          # Accept all licences http://stackoverflow.com/questions/38096225/automatically-accept-all-sdk-licences
          - mkdir -p "$ANDROID_HOME/licenses"
          - echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"
          - echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license"
          # Update android sdk
          - ( sleep 5 && while [ 1 ]; do sleep 1; echo y; done ) | android update sdk --no-ui --filter "extra-android-m2repository" -a
          # Build apk
          - chmod a+x gradlew
          - ./gradlew assembleDebug

Hi, I did the above thing but I am facing error PFA

 

Untitled.png

Hope you solved it by now, but for anyone trying to use what Melwin wrote:

Please try replacing the HTML escaping characters like this from:

* >   =>  turns into `>`  (greater than)

* &  => turns into  '&'  (ampersant)

 

So in the end it looks like:

image: java:8
pipelines:
  default:
    - step:
        script:
          # Download and unzip android sdk
          - wget https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz
          - tar zxvf android-sdk*.tgz
          # Define android Home and add PATHs (After that you can run "android")
          - export ANDROID_HOME="/opt/atlassian/pipelines/agent/build/android-sdk-linux"
          - export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH"
          # Accept all licences http://stackoverflow.com/questions/38096225/automatically-accept-all-sdk-licences
          - mkdir -p "$ANDROID_HOME/licenses"
          - echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"
          - echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license"
          # Update android sdk
          - ( sleep 5 && while [ 1 ]; do sleep 1; echo y; done ) | android update sdk --no-ui --filter "extra-android-m2repository" -a
          # Build apk
          - chmod a+x gradlew
          - ./gradlew assembleDebug

Its fail due to not accepting the licenses. Can you please give me cmd to do thatCapture.PNG

Try adding the content of the licences from your local machine.

Find the files in your `$ANDROID_HOME` to extract the content and put them in the appropriate  place inside your `bitybucket-pipelines.yml`.

`cat $ANDROID_HOME/licences/android-sdk-licence`

and

`cat $ANDROID_HOME/licences/android-sdk-preview-licence`

You should first find out where $ANDROID_HOME points.

After this you can replace them in your `bitbucket-pipelines.yml` file.

It may be that the licences from the example above are expired or something.

dupliacte my fault. 

 

Try using this docker image, which is a a standard ubuntu build pre-populated with android development environment

runmymind/docker-android-sdk:ubuntu-standalone

you can add 

before_script:
- touch local.properties


it will solve this issue.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Calling any interview participants for Bitbucket Data Center

Hi everyone,  We are looking to learn more about development teams’ workflows and pain points, especially around DevOps, integrations, administration, scale, security, and the related challeng...

525 views 6 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you