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.
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:
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" ...)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you can add
before_script:
- touch local.properties
it will solve this issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.