How to setup CircleCI environment JAVA7_HOME for RetroLambda - android

I am using retrolambda in my Android application, and using circleci.com as continuous integration for my github repo.
the problem is I have configured my local mac environment for Java_Home and Java7_Home, and everything is okay, but I don't know how to config circleci yml file for this problem.
here is my application repo:
https://github.com/mmirhoseini/weather_app
here is my local configurations on .bash_profile file:
export JAVA_HOME=`/usr/libexec/java_home`
export JAVA7_HOME=`/usr/libexec/java_home -v 1.7`
this is my circleci.yml file:
#
# Build configuration for Circle CI
#
general:
artifacts:
- /home/ubuntu/weather_app/app/build/outputs/apk/
machine:
environment:
ANDROID_HOME: /usr/local/android-sdk-linux
java:
version: openjdk8
dependencies:
override:
- echo y | android update sdk --no-ui --all --filter tools,platform-tools,build-tools-23.0.3,android-23,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
- (./gradlew test):
timeout: 360
and here is the circleci error log:
> Building 10%When running gradle with java 8, you must set the path to the old jdk, either with property retrolambda.oldJdk or environment variable JAVA5_HOME/JAVA6_HOME/JAVA7_HOME
please help...

finally problem solved, I prepared environment by downloading older java version and setting Java6_home and after that build and run my tests.
here is my circleci.yml file:
#
# Build configuration for Circle CI
#
general:
artifacts:
- /home/ubuntu/weather_app/app/build/outputs/apk/
- /usr/lib/jvm/
machine:
environment:
ANDROID_HOME: /usr/local/android-sdk-linux
JAVA6_HOME: /usr/lib/jvm/java-6-openjdk-amd64
java:
version: openjdk8
dependencies:
override:
- echo y | sudo apt-get update
- echo y | sudo apt-get install libpango-1.0-0
- echo y | sudo apt-get install openjdk-6-jre
- echo y | android update sdk --no-ui --all --filter tools,platform-tools,build-tools-23.0.3,android-23,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
- (./gradlew test):
timeout: 360

Related

Travis CI Android build failed to detect file in Product Flavour directory

My Android project has two product flavour FlavourOne & FlavourTwo and BuildType Debug & Release.
My project src directory has
main
FlavourOneDebug
FlavourOneRelease
FlavourTwoDebug
FlavourTwoRelease
xxx.xxx.test.constant.FlavourConstant is placed in FlavourOneDebug, FlavourOneRelease, FlavourTwoDebug, FlavourTwoRelease and not in main directory
xxx.xxx.test.MainActivity which is placed in main directory imports FlavourConstant
here is my travis.yml
language: android
sudo: required
jdk: oraclejdk8
android:
components:
# The BuildTools version used by your project
- build-tools-26.0.2
# The SDK version used to compile your project
- android-26
# Additional components
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
- $HOME/.android/build-cache
before_install:
- mkdir "$ANDROID_HOME/licenses" || true
- echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"
- echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license"
script:
- ./gradlew build --stacktrace
Travis CI failed to reference FlavourConstant from product flavour directory.
Reference to Travis failed job https://travis-ci.org/KarthikUCH/MokaTest/jobs/527169383
Finally managed to solve the issue, which is actually caused by the flavour source set directory naming.
The Gradle task in Travis expects the flavour directory to be CaseSensitive.
Changed the directory naming form flavoruonedebug to flavoruoneDebug solved the issue

Android project: This job is stuck, because the project doesn't have any runners online assigned to it. Go to Runners page

I have an issue with running Gitlab CI, source code below:
image: openjdk:8-jdk
stages:
- build
- test
- package
#####################################################################
# BUILD
#
.build_template: &build_template_def
stage: build
artifacts:
expire_in: 4 hours
paths:
- app/build/outputs/
- .android/
before_script:
# Extract the SDK version that we're building against
- export ANDROID_COMPILE_SDK=`egrep '^[[:blank:]]+compileSdkVersion' app/build.gradle | awk '{print $2}'`
# Explict output for logging purpose only
- echo $ANDROID_SDK_TOOLS
- echo $ANDROID_COMPILE_SDK
# Fetch the specified SDK tools version to build with
- wget --quiet --output-document=/tmp/sdk-tools-linux.zip https://dl.google.com/android/repository/sdk-tools-linux-${ANDROID_SDK_TOOLS}.zip
- unzip /tmp/sdk-tools-linux.zip -d .android
# Set up environment variables
- export ANDROID_HOME=$PWD/.android
- export PATH=$PATH:$PWD/.android/platform-tools/
# Install platform tools and Android SDK for the compile target
- echo y | .android/tools/bin/sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}"
- chmod +x ./gradlew
build_debug:
<<: *build_template_def
tags:
- buildtag
only:
- develop
- tags
script:
- ./gradlew assembleDebug
build_release:
<<: *build_template_def
only:
- master
script:
- ./gradlew assembleRelease
Even after addition of tags to the jobs, it is saying that stuck.
Also tried changing:
variables:
ANDROID_COMPILE_SDK: "27"
ANDROID_BUILD_TOOLS: "27.0.3"
ANDROID_SDK_TOOLS: "4333796"
Anybody who faced this issue, especially for android project.

CircleCI ./gradlew: Permission denied

I have a Github repository, which is builded on CircleCI. I get following error:
export TERM="dumb" if [ -e ./gradlew ]; then ./gradlew
dependencies;else gradle dependencies;fi bash: line 2: ./gradlew:
Permission denied
export TERM="dumb" if [ -e ./gradlew ]; then ./gradlew
dependencies;else gradle dependencies;fi returned exit code 126
Action failed: gradle dependencies
I can't get what is this caused by, because I give necessary permissions in circle.yml file.
test:
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
- chmod 777 gradlew
- chmod a+x gradlew
- ANDROID_HOME=/usr/local/android-sdk-linux ./gradlew dependencies
- ./gradlew testVanillaDebugUnitTest -PdisablePreDex
- echo "y" | sudo /opt/google-cloud-sdk/bin/gcloud beta test android run --app app/build/outputs/apk/app-vanilla-debug.apk --test app/build/outputs/apk/app-vanilla-debug-androidTest.apk --device-ids Nexus5 --os-version-ids 22 --locales en --orientations portrait
run: chmod +x gradlew
run: ./gradlew assemble
So, first set permission, then run the command you want
Looking at you circle.yml (found here), the failure is not from lines #25 or #26, it's line #14.
Please notice that order of execution is
dependencies:pre
dependencies:post
test:override
test:post
So what you need to do is remove lines 23, 24 and add chmod +x gradlew as the first command in dependencies:pre

CircleCI build getting "Could not find com.google.android.gms:play-services-identity:11.0.1"

I'm trying to build an Android app on CircleCI using this circle.yml file
machine:
java:
version: oraclejdk8
environment:
# Java options
JAVA_OPTS: "-Xms512m -Xmx2048m"
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
dependencies:
pre:
# Download and install latest(26.0.2) sdk-tools revision
- wget https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip
- mkdir sdk
- unzip -d sdk sdk-tools-linux-3859397.zip
# Accepts SDK licenses
- mkdir "$ANDROID_HOME/licenses" || true
- echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"
- echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license"
# Install Android SDKs and additional repositories
- echo y | sdk/tools/bin/sdkmanager --channel=2 "build-tools;25.0.3" "platform-tools" "tools"
- echo y | sdk/tools/bin/sdkmanager --channel=2 "extras;google;m2repository" "extras;android;m2repository" "extras;google;google_play_services"
test:
override:
# Generate a debug-apk
- ./gradlew assembleAppseeOffDebug -PdisablePreDex
# Copy the generated apk files to Circle-CI Artifacts
- cp -r app/build/outputs/apk/ $CIRCLE_ARTIFACTS
# Copy the test results to Circle-CI Artifacts
- cp -r app/build/outputs/androidTest-results/* $CIRCLE_TEST_REPORTS
The problem is that during the gradle build phase, I got this error
Could not find com.google.firebase:firebase-messaging:11.0.1.
Searched in the following locations:
file:/usr/local/android-sdk-linux/extras/m2repository/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.pom
file:/usr/local/android-sdk-linux/extras/m2repository/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.jar
file:/usr/local/android-sdk-linux/extras/google/m2repository/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.pom
file:/usr/local/android-sdk-linux/extras/google/m2repository/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.jar
file:/usr/local/android-sdk-linux/extras/android/m2repository/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.pom
file:/usr/local/android-sdk-linux/extras/android/m2repository/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.jar
http://dl.bintray.com/populov/maven/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.pom
http://dl.bintray.com/populov/maven/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.jar
https://jcenter.bintray.com/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.pom
https://jcenter.bintray.com/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.jar
https://oss.sonatype.org/content/repositories/snapshots/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.pom
https://oss.sonatype.org/content/repositories/snapshots/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.jar
https://jitpack.io/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.pom
https://jitpack.io/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.jar
https://dl.google.com/dl/android/maven2/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.pom
https://dl.google.com/dl/android/maven2/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.jar
https://maven.fabric.io/public/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.pom
https://maven.fabric.io/public/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.jar
https://zendesk.artifactoryonline.com/zendesk/repo/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.pom
https://zendesk.artifactoryonline.com/zendesk/repo/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.jar
Is there any sdk dependency that I'm not declaring in circle.yml file?
The problem was with the executor (oraclejdk8),that does not had the correct Android SDK and Google repositories installed.
I solved the problem by migrating from CircleCI 1.0 to 2.0 and setting bitriseio/docker-android:latest - which has the correct repositories installed by default - as docker image.
Here's my final config.yml
version: 2
jobs:
build:
working_directory: /opt/working
docker:
- image: bitriseio/docker-android:latest
environment:
# Java options
JAVA_OPTS: "-Xms512m -Xmx2048m"
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
steps:
- checkout
- run:
name: Accepts License
command: echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license"
- run:
name: Assemble & Test
command: ./gradlew assembleDebug testDebugUnitTest
- store_artifacts:
path: app/build/reports/tests/
destination: tests_reports/
- store_test_results:
path: "app/build/test-results/testDebugUnitTest/"
- store_artifacts:
path: app/build/outputs/apk/
destination: apks/

CircleCI "Some errors occurred while attempting to infer information about your code"

I'm trying to build an Android project using CircleCI, but every time I run a build, the build completes in the Configure Build task and I get this message:
Some errors occurred while attempting to infer information about your code.
Also, when this occurs, CircleCI automatically tries to rebuild the branch, causing a loop, because every new build keeps failing.
Here's my circle.yml file
version: 1
machine:
java:
version: oraclejdk8
environment:
# Java options
JAVA_OPTS: "-Xms512m -Xmx2048m"
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
dependencies:
pre:
# Install the android packages
- echo y | android update sdk --no-ui --all --filter "build-tools-25.0.3"
test:
pre:
override:
# Generate a debug-apk
- ./gradlew assembleAppseeOffDebug -PdisablePreDex
# Copy the generated apk files to Circle-CI Artifacts
- cp -r app/build/outputs/apk/ $CIRCLE_ARTIFACTS
# Copy the test results to Circle-CI Artifacts
- cp -r app/build/outputs/androidTest-results/* $CIRCLE_TEST_REPORTS
Solved the problem by following this circle.yml example
In 1, after the test tag there's an override tag, but in my circle.yml file there's a pre tag. Removing that pre tag solved the problem.
Final circle.yml file
version: 1
machine:
java:
version: oraclejdk8
environment:
# Java options
JAVA_OPTS: "-Xms512m -Xmx2048m"
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
dependencies:
pre:
# Install the android packages
- echo y | android update sdk --no-ui --all --filter "build-tools-25.0.3
test:
# REMOVED pre TAG
override:
# Generate a debug-apk
- ./gradlew assembleAppseeOffDebug -PdisablePreDex
# Copy the generated apk files to Circle-CI Artifacts
- cp -r app/build/outputs/apk/ $CIRCLE_ARTIFACTS
# Copy the test results to Circle-CI Artifacts
- cp -r app/build/outputs/androidTest-results/* $CIRCLE_TEST_REPORTS

Categories

Resources