GithubHelp home page GithubHelp logo

mobiledevops / android-sdk-image Goto Github PK

View Code? Open in Web Editor NEW
34.0 3.0 7.0 39 KB

Docker image for Android SDK builds

Home Page: https://hub.docker.com/r/mobiledevops/android-sdk-image

License: MIT License

Dockerfile 86.99% Makefile 13.01%
android android-sdk docker dockerfile dockerhub dockerhub-image

android-sdk-image's Introduction

Docker image for Android SDK

Docker image to build an Android app *.apk. The image contains the latest Android SDK tools, Gradle 8.2 and the Android SDK platform packages from packages.txt:

  • build-tools;34.0.0
  • build-tools;33.0.2
  • platforms;android-34
  • platforms;android-34-ext8
  • platforms;android-33
  • platform-tools
  • extras;android;m2repository
  • extras;google;google_play_services
  • extras;google;m2repository
  • add-ons;addon-google_apis-google-24

The releases tags are oriented on the base of the Build Tools version from packages.txt.

Usage

The image can be used on different cloud build services or own hosted pipeline solutions like Travis CI, CircleCI or GitLab CI/CD.

CircleCI

CircleCI supports the direct specification of a Docker image and checks out the source code in it: https://circleci.com/docs/2.0/circleci-images/

Therefore you execute your CI script directly in the container.

Example:

# .circleci/config.yml
version: 2.1
jobs:
  build:
    docker: 
      - image: mobiledevops/android-sdk-image:34.0.0
    steps:
      - checkout
      - run:
          name: Android Build
          command: ./gradlew clean assembleRelease

Example Project: https://github.com/mobiledevops/android-ci-demo

Travis CI

To use a Docker container on Travis CI, you have to pull, run and execute it manually because Travis CI has no Docker executor: https://docs.travis-ci.com/user/docker/

And to prevent to do a new checkout of the source code in the Docker image, you can copy the code into the container via tar (see https://docs.docker.com/engine/reference/commandline/cp/). To execute your CI script, use docker exec with the container name.

Example:

# .travis.yml
dist: bionic

services:
  - docker

env:
  - DOCKER_IMAGE=mobiledevops/android-sdk-image:34.0.0

before_install:
  - docker pull $DOCKER_IMAGE
  - docker run --name android_ci -t -d $DOCKER_IMAGE /bin/sh
  - tar Ccf . - . | docker exec -i android_ci tar Cxf /home/mobiledevops/app -

script:
  - docker exec android_ci ./gradlew clean assembleRelease

Example Project: https://github.com/mobiledevops/android-ci-demo

GitLab CI

GitLab CI/CD supports to run jobs on provided Docker images: https://docs.gitlab.com/runner/executors/docker.html

Therefore you execute your CI script directly in the container.

Example:

# .gitlab-ci.yml
image: mobiledevops/android-sdk-image:34.0.0

stages:
    - build

release_build:
    stage: build
    tags:
      - shared
    script:
        - ./gradlew clean assembleRelease

Example Project: https://gitlab.com/mobiledevops/android-ci-demo


Contributing

Code of Conduct

android-sdk-image's People

Contributors

messeb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

android-sdk-image's Issues

`apkanalyser` which is part of cmdline-tools is able to run due to exception

When running apkanalyzer it won't run and throws an exception.

Exception in thread "main" java.lang.IllegalStateException: The tools directory property is not set, please make sure you are executing apkanalyzer. Got /opt/android-sdk-linux/cmdline-tools
        at com.android.tools.apk.analyzer.ApkAnalyzerCli.getAaptInvokerFromSdk(ApkAnalyzerCli.java:271)
        at com.android.tools.apk.analyzer.ApkAnalyzerCli.main(ApkAnalyzerCli.java:128)

Expected behaviour

When running apkanalyzer it should show the help text of apk analyzer

Actual behaviour

It throws an exception.

Steps to reproduce the behaviour

  • run apkanalyzer (located in /opt/android-sdk-linux/cmdline-tools/bin/apkanalyzer)

Which Docker version is used?

Docker for mac desktop 24.0.6

Which host operation system is used?

  • Linux
  • Windows
  • macOS

Could not resolve com.android.tools.build:gradle:8.1.1.

Hello, i tried to build my app with this image with no success.
i got this error message.
I run my job with gitlab-runner in my machine.
Can you please help me out with this?

assembleRelease:
  image: mobiledevops/android-sdk-image:30.0.3
  stage: build
  before_script:
     # Writing GE_JOB_ID variable to environment file, will need the value in the next stage.
     - echo GE_JOB_ID=$CI_JOB_ID >> generate_executables.env
  script:
    - mkdir bin
    - ./gradlew clean assembleRelease
    - cp app/build/outputs/apk/release/app-release.apk bin/${APK_BINARY}
    - export JOB_ID=$CI_JOB_ID
  artifacts:
    paths:
      - bin/
    reports:
      dotenv: generate_executables.env
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '8.1.1' apply false
    id 'com.android.library' version '8.1.1' apply false
    id 'org.jetbrains.kotlin.android' version '1.8.22' apply false
}

tasks.register('clean', Delete) {
    delete rootProject.buildDir
}
plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'kotlin-kapt'
}

android {
    namespace 'app.x.sklad'
    compileSdk 34

    defaultConfig {
        applicationId "app.x.sklad"
        minSdk 33
        targetSdk 33
        versionCode 3
        versionName "1.0.4"

        ...
    }

    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile(
                    'proguard-android-optimize.txt'),
                    'proguard-rules.pro'
        }       
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
    kotlinOptions {
        jvmTarget = '17'
    }
    buildFeatures {
        compose true
        dataBinding true
    }
    composeOptions {
        kotlinCompilerExtensionVersion '1.4.8'
    }
}

dependencies {
    implementation "androidx.compose.runtime:runtime:1.5.1"
    implementation 'androidx.core:core-ktx:1.12.0'
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.9.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation "androidx.camera:camera-camera2:1.2.3"
    implementation 'androidx.camera:camera-mlkit-vision:1.3.0-beta02'
    implementation 'com.google.mlkit:barcode-scanning:17.2.0'
}

Actual behaviour

Starting a Gradle Daemon (subsequent builds will be faster)

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring root project 'Sklad'.

Could not resolve all files for configuration ':classpath'.
Could not resolve com.android.tools.build:gradle:8.1.1.
Required by:
project : > com.android.application:com.android.application.gradle.plugin:8.1.1
project : > com.android.library:com.android.library.gradle.plugin:8.1.1
> No matching variant of com.android.tools.build:gradle:8.1.1 was found. The consumer was configured to find a library for use during runtime, compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.3' but:
- Variant 'apiElements' capability com.android.tools.build:gradle:8.1.1 declares a library, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares a component for use during compile-time, compatible with Java 11 and the consumer needed a component for use during runtime, compatible with Java 8
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '8.3')
- Variant 'javadocElements' capability com.android.tools.build:gradle:8.1.1 declares a component for use during runtime, and its dependencies declared externally:
- Incompatible because this component declares documentation and the consumer needed a library
- Other compatible attributes:
- Doesn't say anything about its target Java version (required compatibility with Java 8)
- Doesn't say anything about its elements (required them packaged as a jar)
- Doesn't say anything about org.gradle.plugin.api-version (required '8.3')
- Variant 'runtimeElements' capability com.android.tools.build:gradle:8.1.1 declares a library for use during runtime, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares a component, compatible with Java 11 and the consumer needed a component, compatible with Java 8
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '8.3')
- Variant 'sourcesElements' capability com.android.tools.build:gradle:8.1.1 declares a component for use during runtime, and its dependencies declared externally:
- Incompatible because this component declares documentation and the consumer needed a library
- Other compatible attributes:
- Doesn't say anything about its target Java version (required compatibility with Java 8)
- Doesn't say anything about its elements (required them packaged as a jar)
- Doesn't say anything about org.gradle.plugin.api-version (required '8.3')
...

Steps to reproduce the behaviour

Which Docker version is used?

24.0.5

Which host operation system is used?

  • Linux
  • [ ] Windows
  • [ ] macOS

Installing new packages with apt-get

Is it somehow possible to install other packages with apt-get? I have seen that sudo is not installed and the default user has no root rights

Which host operation system is used?

  • Linux
  • Windows
  • macOS

Do you expect to support Google Cloud Build?

Short summary ...

Expected behaviour

It seems the image should also support APK building on Google Cloud Build platform. Are you going to include it also in the instructions?

Actual behaviour

There is no guide included on how to set up '/cloudbuild.yaml' for this although it seems it should fit. I am currently trying to set it up.

Steps to reproduce the behaviour

Which Docker version is used?

Which host operation system is used?

Google Cloud Build

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.