circleci-public / android-orb Goto Github PK
View Code? Open in Web Editor NEWAn orb for working with Android on CircleCI
Home Page: https://circleci.com/developer/orbs/orb/circleci/android
License: MIT License
An orb for working with Android on CircleCI
Home Page: https://circleci.com/developer/orbs/orb/circleci/android
License: MIT License
2.0.3
The ANDROID_NDK_HOME env variable is not set to the correct path since the SDK manager is used to install the NDK. It should be ${ANDROID_HOME}/ndk/<< parameters.version >>
but it's set to /opt/android/<< parameters.version >>
2.3.0
The documentation states that 17 is now the default, but 11 was still being applied. My build.gradle
files are targeting Java 17, but ran into the same problem so I tried to explicitly set java 17 in the config.yml
, and then this error occurred. Either way, I'm unable to have a proper JAVA17 environment in circleci.
build_debug_job:
<<: *android_config
steps:
- checkout
- android/change-java-version:
java-version: 17
#!/bin/bash -eo pipefail
#!/bin/bash
CURRENT_JAVA_VER="$( java -version 2>&1 | head -1 | cut -d'"' -f2 | sed '/^1\./s///' | cut -d'.' -f1 )"
CURRENT_JAVAC_VER="$( javac -version 2>&1 | head -1 | cut -f 2- -d ' ' | sed '/^1\./s///' | cut -d'.' -f1 )"
echo "Current Java Version: $CURRENT_JAVA_VER"
echo "Current Java Compiler Version : $CURRENT_JAVAC_VER"
if [ "$CURRENT_JAVA_VER" -ne "${PARAM_JAVA_VER}" ]; then
if [ "${PARAM_JAVA_VER}" -eq 8 ] || [ "${PARAM_JAVA_VER}" -eq 17 ]; then
if [ "${PARAM_JAVA_VER}" -eq 8 ]; then
sudo update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
else
sudo update-alternatives --set java /usr/lib/jvm/java-17-openjdk-amd64/bin/java
fi
sudo update-alternatives --set javac /usr/lib/jvm/java-"${PARAM_JAVA_VER}"-openjdk-amd64/bin/javac
else
sudo apt install openjdk-"${PARAM_JAVA_VER}"-jdk
sudo update-alternatives --set javac /usr/lib/jvm/java-"${PARAM_JAVA_VER}"-openjdk-amd64/bin/javac
sudo update-alternatives --set java /usr/lib/jvm/java-"${PARAM_JAVA_VER}"-openjdk-amd64/bin/java
fi
echo "export JAVA_HOME=/usr/lib/jvm/java-${PARAM_JAVA_VER}-openjdk-amd64" >> ~/.bashrc
echo "export PATH=$JAVA_HOME/bin:$PATH" >> ~/.bashrc
fi
NEW_JAVA_VER="$( java -version 2>&1 | head -1 | cut -d'"' -f2 | sed '/^1\./s///' | cut -d'.' -f1 )"
NEW_JAVAC_VER="$( javac -version 2>&1 | head -1 | cut -f 2- -d ' ' | sed '/^1\./s///' | cut -d'.' -f1 )"
echo "New Java Version : $NEW_JAVA_VER"
echo "New Java Compiler Version : $NEW_JAVAC_VER"
Current Java Version: 11
Current Java Compiler Version : 11
update-alternatives: error: alternative /usr/lib/jvm/java-17-openjdk-amd64/bin/java for java not registered; not setting
Exited with code exit status 2
CircleCI received exit code 2
JAVA 17 circleci environment should be configured to be able to resolve compile time errors related to the Gradle 8.0's requirements.
circleci/[email protected]
Config file: https://github.com/facebook/react-native/blob/600d1d4435869fb861cd8c28a685cac1b54eec11/.circleci/config.yml.
Job: test_e2e_android
In React Native repository, we're implementing E2E tests, for this we need to launch Android emulator, the problem is when I try launching emulators with newer SDK the CI is booting emulator for too long. I tried with SDK 33, 32, 31, 30, see here. It worked with SDK 29, but this is quite old and we wouldn't like to use it.
Booting emulator should not take so long.
Orb version:
android: circleci/[email protected]
This is what i have in my config.file:
- android/create-avd:
system-image: "system-images;android-29;google_apis;x86"
avd-name: Pixel_2_API_29
install: true
Trying to add the background: true attribute to the step resulted with a failure when executing "circleci config validate", as follows, as the attribute is unnexpected:
https://discuss.circleci.com/t/create-avd-in-the-background/46840/2
2.2.0
The contents of the keystore properties JSON file created in the android/create-google-play-key
step is just the name of the environment variable used to store the JSON, e.g. "GOOGLE_PLAY_KEY"
.
The file should contain the JSON data stored in the $GOOGLE_PLAY_KEY
environment variable.
Looks like a case of echo GOOGLE_PLAY_KEY > google-play-key.json
instead of echo $GOOGLE_PLAY_KEY > google-play-key.json
.
Happy to jump in with a PR here if someone can just confirm that I'm not mistaken!
Before adopting this orb in order to attach screenshoot of our ui tests we run the following commands:
Now we cannot run "adb pull" while it is still running since "adb "is started and killed inside the command: start-emulator-and-run-tests command
How can we attach screenshot images to the "CI's Artifacts" tab?
It is possible to add a parameter to start-emulator-and-run-tests ? Something like
adb_pull_destination_folder? I
circleci/[email protected]
We recently updated our android application and gradle project to use gradle 8.0, on our machines everything is working correctly, but while running the project in circleCI we are receiving that error.
is there a way to add java 17 to the Android Orb machine? any plans to add java 17 by default?
Where:
Build file '/home/circleci/project/app/build.gradle' line: 3
What went wrong:
A problem occurred evaluating project ':app'.
Failed to apply plugin 'com.android.internal.application'.
Android Gradle plugin requires Java 17 to run. You are currently using Java 11.
Your current JDK is located in /usr/lib/jvm/java-11-openjdk-amd64
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changingorg.gradle.java.home
ingradle.properties
.
CircleCi could provide a new Android Orb Version with Java 17 for projects using gradle 8.0
Orb can no longer accept step arguments that are environment variables.
I have a step that looks like this:
run-andoid-emulator-and-tests:
steps:
- android/start-emulator-and-run-tests:
additional-avd-args: "-d pixel_3a -c 1G"
additional-emulator-args: "-memory 4096 -cores 3"
test-command: $GRADLE_TEST_COMMAND
system-image: $SYSTEM_IMAGE
This works great on 2.1.0. On 2.1.1 however, it fails at "Create avd 'test'":
#!/bin/bash -eo pipefail
#!/bin/bash
echo "no" | avdmanager --verbose create avd -n ${PARAM_AVD_NAME} -k ${PARAM_SYSTEM_IMAGE} ${PARAM_ADDITIONAL_ARGS}
Error: Package path is not valid. Valid system image paths are:ository...
system-images;android-29;default;x86_64
null
Exited with code exit status 1
CircleCI received exit code 1
If I replace system-image: $SYSTEM_IMAGE
with a hard-coded value, the create AVD stage works, but then the "Run tests with max tries of 2" step fails with:
#!/bin/bash -eo pipefail
#!/bin/bash
run_with_retry() {
MAX_TRIES=${PARAM_MAX_TRIES}
n=1
until [ $n -gt $MAX_TRIES ]
do
echo "Starting test attempt $n"
${PARAM_TEST_COMMAND} && break
n=$((n+1))
sleep "${PARAM_RETRY_INTERVAL}"
done
if [ $n -gt $MAX_TRIES ]; then
echo "Max tries reached (${PARAM_MAX_TRIES})"
exit 1
fi
}
run_with_retry
Starting test attempt 1
environment: line 7: ${GRADLE_TEST_COMMAND}: command not found
Starting test attempt 2
environment: line 7: ${GRADLE_TEST_COMMAND}: command not found
Max tries reached (2)
Exited with code exit status 1
CircleCI received exit code 1
Environemnt var values should be passed through to the orb correctly, as they were in 2.1.0
v2.1.1
I noticed that the latest @ v2.1.1 modified the restore-gradle-cache
command, as per #48
Running this on a sample (empty) project. I noted this command is failing with the following error:
find: paths must precede expression: `\('
I found one possible fix would be to eval
the find command.
sample job after
eval
fix: https://app.circleci.com/pipelines/github/kelvintaywl-cci/android-explore/24/workflows/ff85596c-e78f-4ef8-955b-52ae9224a747/jobs/39?invite=true#step-104-5
However, I'm not sure if that's the best approach !
I also observed that, for the "test-emulator-commands" job triggered from PR #48, it somehow did not pick up the code changes from #48 and this ran fine;
It was running with the restore-gradle-cache
command from v2.1.0 instead.
We can see this under the config, when clicking on "Compiled":
https://app.circleci.com/projects/github/CircleCI-Public/android-orb/config/?branchName=&pipelineNumber=329
restore-gradle-cache
command for v2.1.1. should succeed.
Hello,
It seems like the circleci/android:api-<version>
images that this orb uses will be getting deprecated by CircleCI on December 31st.
Sources:
https://discuss.circleci.com/t/legacy-convenience-image-deprecation/41034
https://circleci.com/blog/announcing-our-next-generation-convenience-images-smaller-faster-more-deterministic/
https://circleci.com/developer/images/image/cimg/android
This should probably be migrated to use the new cimg/android
images.
1.0.3
I tried to upgrade the NDK version to r23b but it failed with error: curl: (22) The requested URL returned error: 404 Not Found
.
The URL used to install the NDK is: https://dl.google.com/android/repository/android-ndk-r23b-linux-x86_64.zip
The URL should be https://dl.google.com/android/repository/android-ndk-r23b-linux.zip
Based off #54, pulling screenshots has proven difficult without providing a destination for the adb pull
command. Adding a parameter for users to specify and therefore persist the artifacts will be helpful for testing
2.5.0
I have this step in my CircleCI config:
- android/install-ndk:
version: "26.2.11394342"
The issue is that ANDROID_NDK_HOME
is set to /opt/android/26.2.11394342
whereas the NDK is installed at path /opt/android/sdk/ndk/26.2.11394342
.
See the corresponding faulty code:
if [[ -d "${HOME}/android-sdk/ndk/${PARAM_VER}" ]]; then
android_ndk_home="$HOME/android-sdk/ndk/${PARAM_VER}"
elif [[ -d "/opt/android/sdk/ndk/${PARAM_VER}" ]]; then
android_ndk_home="/opt/android/${PARAM_VER}"
1.0.3
CI Config:
- android/install-ndk:
ndk-version: android-ndk-r21e
ndk-sha: c3ebc83c96a4d7f539bd72c241b2be9dcd29bda9
Gradle release config:
android {
compileSdkVersion 29
ndkVersion "21.4.7075529"
buildTypes {
release {
ndk {
debugSymbolLevel 'FULL'
}
}
}
}
/tmp/android-ndk-r21e.zip: OK
Android NDK installed
CircleCI received exit code 0
Successful install. Great!
[22:07:13]: ▸ FAILURE: Build failed with an exception.
[22:07:13]: ▸ * What went wrong:
[22:07:13]: ▸ Execution failed for task ':app:extractReleaseNativeDebugMetadata'.
[22:07:13]: ▸ > NDK is not installed
Nope, not installed.
NDK is, in fact installed - and works. Is there something that was missed here?
2.3.0
Fails to start emulator on docker image due to GPU, no settings on gpu work.
Starting emulator with arguments -gpu swiftshader_indirect
INFO | Android emulator version 32.1.14.0 (build_id 10330179) (CL:N/A)
INFO | Found systemPath /home/circleci/android-sdk/system-images/android-30/google_apis/x86/
INFO | Storing crashdata in: /tmp/android-unknown/emu-crash.db, detection is enabled
INFO | Duplicate loglines will be removed, if you wish to see each indiviudal line launch with the -log-nofilter flag.
WARNING | Please update the emulator to one that supports the feature(s): Vulkan
WARNING | Failed to process .ini file /home/circleci/.android/avd/test.avd/quickbootChoice.ini for reading.
ERROR | x86 emulation currently requires hardware acceleration!
CPU acceleration status: KVM requires a CPU that supports vmx or svm
More info on configuring VM acceleration on Linux:
https://developer.android.com/studio/run/emulator-acceleration#vm-linux
General information on acceleration: https://developer.android.com/studio/run/emulator-acceleration.
Exited with code exit status 1
Using android-machine the emulator looks like it does start and then fails because it can't connect add.
executor:
name: android/android-machine
resource-class: 2xlarge
tag: 2023.07.1
ERROR | Unable to connect to adb daemon on port: 5037
INFO | Revoking microphone permissions for Google App.
INFO | Wait for emulator (pid 3618) 20 seconds to shutdown gracefully before kill;you can set environment variable ANDROID_EMULATOR_WAIT_TIME_BEFORE_KILL(in seconds) to change the default value (20 seconds)
Using an example from https://dev.to/roselinebassey/android-automate-instrumented-and-unit-tests-with-circleci-1igo fails too!
test_ui:
steps:
# Then start the emulator and run the Instrumentation tests!
- run:
name: installing emulator and Running Instrumentation tests
command: |
sdkmanager "platform-tools" "platforms;android-29" "build-tools;30.0.0" "emulator"
sdkmanager "system-images;android-29;google_apis;x86"
echo no | avdmanager create avd -n test-emulator -k "system-images;android-29;google_apis;x86"
emulator -avd test-emulator -noaudio -no-boot-anim -gpu off -no-window &
adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;'
adb shell wm dismiss-keyguard
sleep 1
adb shell settings put global window_animation_scale 0
adb shell settings put global transition_animation_scale 0
adb shell settings put global animator_duration_scale 0
./gradlew connectedAndroidTest
Emulator should run and tests run
version: 2.1
orbs:
android: circleci/[email protected]
...
jobs:
android-test:
executor:
name: android/android-machine
resource-class: xlarge
steps:
- checkout
- android/start-emulator-and-run-tests:
test-command: ./gradlew android-auto:connectedDebugAndroidTest
system-image: system-images;android-30;google_apis;x86
- run:
name: Save test results
command: |
mkdir -p ~/mapbox_test/
adb pull sdcard/Download/mapbox_test ~/mapbox_test/
when: on_fail
- store_artifacts:
path: ~/mapbox_test/
We are updating our compile version to 30 in an app. But a test checking for isGooglePlayServicesAvailable
started failing after this upgrade.
android {
- compileSdkVersion(29)
+ compileSdkVersion(30)
defaultConfig {
applicationId = "com.mapbox.app"
minSdkVersion(23)
- targetSdkVersion(29)
+ targetSdkVersion(30)
}
class LocationEngineProviderTest {
@Test
fun checkGooglePlayServicesAvailable() {
val activityScenario = launchActivity<NavigationTestActivity>()
activityScenario.onActivity { activity ->
Assert.assertEquals(
"Google location services have to be available",
ConnectionResult.SUCCESS,
GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(activity)
)
}
}
}
The LocationEngineProviderTest
should pass because we want to test integrations with google play services
In restore-gradle-cache.yml
, the default find
only takes into consideration build.gradle
. It should also look for build.gradle.kts
by default along with settings.gradle
and settings.gradle.kts
.
I got error when using pre-test-command
My config.yml step:
- android/run-tests:
max-tries: 1
pre-test-command: source /etc/environment
test-command: mvn clean test -DxmlFile=testngCompileCode.xml
Error in CircleCI:
Starting test attempt 1
environment: line 8: mvn: command not found
Max tries reached (1)
Exited with code exit status 1
CircleCI received exit code 1
pre-test-command: source /etc/environment
should work
circleci/[email protected]
fastlane-deploy command does not exist
fastlane-deply command to exist
circleci/[email protected]
New issue appeared on Circle since few days when I install the NDK. This error is not always displayed, maybe 50% of our builds are concerned. I have tried the ndk r21d and the error is the same.
- android/install-ndk: ndk-version: android-ndk-r19c
Error shown in circle
`#!/bin/bash -eo pipefail
[ -w /usr/local/bin ] && SUDO="" || SUDO=sudo
$SUDO curl --silent --show-error --location --fail --retry 3
--output /tmp/android-ndk-r19c.zip
https://dl.google.com/android/repository/android-ndk-r19c-linux-x86_64.zip
$SUDO echo "fd94d0be6017c6acbd193eb95e09cf4b6f61b834 /tmp/android-ndk-r19c.zip" > /tmp/android-ndk-r19c.zip.sha1
sha1sum -c /tmp/android-ndk-r19c.zip.sha1
$SUDO unzip -q /tmp/android-ndk-r19c.zip -d /opt/android
$SUDO rm -f /tmp/android-ndk-r19c*
$SUDO chown -R circleci:circleci /opt/android/android-ndk-r19c
echo "export ANDROID_NDK_HOME=/opt/android/android-ndk-r19c" >> $BASH_ENV
if [[ -d /opt/android/android-ndk-r19c &&
-n "$(ls -A /opt/android/android-ndk-r19c)" ]]; then
echo "Android NDK installed"
else
echo "Android NDK did not install successfully"
exit 1
fi
curl: (16) Error in the HTTP2 framing layer
Exited with code exit status 16
CircleCI received exit code 16`
Should install the ndk as usual
These images include OpenJDK v11 and v8, which 11 being the default. Ubuntu (the base OS) provides commands to switch easily but having the orb tap into that would make things smoother.
is there a way to map defined modules to the result of the circleci test split command output to $TESTFILES to run the correct set of modules in each parallel container
./gradlew mylibrary:connectedAndroidTest
2.0.3
android orb version 1 was able to digest and use matrix job parameters in the run ui tests step (### Expected behavior)
- android/run-ui-tests:
matrix:
parameters:
system-image:
- system-images;android-30;default;x86_64
#- system-images;android-31;default;x86_64 // Test with newest release
name: "Test Android UI: <<matrix.system-image>>"
now fails with:
circleci config validate
Error: Error calling workflow: 'build_test_deploy'
Error calling job: 'android/run-ui-tests'
Unexpected executor invocation format
The value of `name` must be a string
Examples of correct executor invocation:
executor: string-executor-name
executor: {name: string-executor-name}
executor: << parameters.executor-type-parameter >>
v2.0.3
In #35, the RC009 was included in the exclusion list of the orb tools review. This review checks if there are commands with more than 64 characters (i.e. shell inside the yaml).
Orb development best practices dictate that shell should be inside .sh
files, therefore, commands inside the yaml, should not contain code.
Commands with more than 64 characters of shell code should be extracted to their own .sh
file and the RC009 review should not be excluded.
tried using different images from the default 29 in the examples.
android-30, android-S were not found. android-24 was found but gradle skipped my tests.
Find the images that are requested.
2.5.0
Using gradle 8.9 and cimg/android:2024.07
Running
- android/change-java-version:
java-version: 17
- run:
name: Print build environment
command: ./gradlew buildEnvironment
Print respectively :
Current Java Version: 21
Current Java Compiler Version : 21
^@^@update-alternatives: using /usr/lib/jvm/java-17-openjdk-amd64/bin/java to provide /usr/bin/java (java) in manual mode
update-alternatives: using /usr/lib/jvm/java-17-openjdk-amd64/bin/javac to provide /usr/bin/javac (javac) in manual mode
New Java Version : 17
New Java Compiler Version : 17
And
> Task :buildEnvironment
Daemon JVM: Ubuntu JDK 21.0.3+9-Ubuntu-1ubuntu122.04.1
| Location: /usr/lib/jvm/java-21-openjdk-amd64
| Language Version: 21
| Vendor: Ubuntu
| Architecture: amd64
| Is JDK: true
The gradle task should use the requested jdk
2.1.2
After starting an emulator with the system image system-images;android-31;default;x86_64
, the wait-for-emulator
command seems to hang indefinitely:
Waiting for Device.* daemon not running; starting now at tcp:5037
* daemon started successfully
..............
Device is ready after 28 seconds
Waiting for Shell.
Shell is ready after 28 seconds
Waiting for Boot animation complete.....................
Boot animation complete is ready after 70 seconds
Waiting for Boot animation exited................................................................................................................................................................................................................................................................................................................................................................................................
I have reproduced this problem with a minimal config, and you can see in this workflow that this succeeds pretty quickly on the Android 30 image, but bumping it to 31 makes it hang.
2.3.0
I wanted to upgrade all of our CI executor images to the newest ones. When specifying version 2023.10.2
, CircleCI fails with the error:
Job was rejected because resource class xlarge, image android:2023.10.2 is not a valid resource class
.
This happens only for the android-machine
executor; android-docker
runs with this version.
As per the official docs, both android-docker
and android-machine
support the resource class and many others:
https://circleci.com/developer/orbs/orb/circleci/android#executors-android-docker
https://circleci.com/developer/orbs/orb/circleci/android#executors-android-machine
After testing more, all versions after 2023.08.1
fail in the same exact way. The resource class just doesn't exist for the later images.
The CI pipelines should run normally without any errors.
version: 2.1
orbs:
android: circleci/[email protected]
jobs:
android-test:
executor:
name: android/android-machine
resource-class: xlarge
tag: 2023.10.2
Here's the excerpt from the official docs:
parameters:
resource-class:
default: medium
description: Resource class used for the executor.
enum:
- small
- medium
- medium+
- large
- xlarge
- 2xlarge
- 2xlarge+
type: enum
tag:
description: >
The Android image tag to use.
Choose a tag from
https://circleci.com/developer/images/image/cimg/android#image-tags.
type: string
2.2.0
Added no-output-timeout
parameter to start-emulator-and-run-tests
and noticed that it still timed out at 10m despite having it set to 1h.
Example:
- android/start-emulator-and-run-tests:
avd-name: android-phone-32
additional-avd-args: "-d pixel_6"
system-image: system-images;android-32;google_apis;x86_64
no-output-timeout: 1h
...etc
Should actually set the no output timeout of the test command.
Created a small PR #69 to solve this as it seems that the no-output-timeout
parameter from start-emulator-and-run-tests
is being passed to run-tests
, but run-tests
is not actually setting it on the command running the run-tests script.
When upgraded from 2.1.2 to 2.3.0, started seeing the following error:
cat: /sys/fs/cgroup/memory/memory.max_usage_in_bytes: No such file or directory
for my command
name: Log memory usage
command: cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes | awk -v var=" GB" '{printf $1/1000000000; printf var}'
Either keep working or documentation where cgroups changes is visibe?
0.1.0
After running android/install-ndk
, ANDROID_NDK_HOME
is empty. It seems like it's not correctly exported.
It should be set to the NDK path.
2.5.0
Evaluates $PATH at the time when the command runs, rather than when the bashrc is sourced. It will overwrite other changes to the PATH made in following steps. e.g. by the flutter orb.
Also I see that $BASH_ENV is recommended instead of ~/.bashrc in the docs.
It also evaluated JAVA_HOME at the wrong time which might explain #93.
2.0.3
The save-gradle-cache
command expects a /tmp/gradle_cache_seed file to exist, to generate a cache key.
I am not sure the rationale for this hardcoded value, but for builds where this file is not existing, the command will fail.
This can affect using the start-emulator-and-run-tests
command as well, since it calls on the save-gradle-cache
command by default.
Perhaps allow this file to be configurable, via a parameter?
0.2.3
SDK 30 is officially released. Would be great to include it as an enum for the sdk-version parameter for the android executor.
We should test what PR #50 fixes. Setting a default and not should be tested.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.