# Android Challenges and circle.yml file

**URL:** <https://discuss.circleci.com/t/android-challenges-and-circle-yml-file/1552>\
**Category:** Mobile\
**Tags:** circle-yml, android\
**Created:** [January 14, 2016, 9:27pm UTC](https://discuss.circleci.com/t/android-challenges-and-circle-yml-file/1552 "2016-01-14T21:27:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kbourne](https://avatars.discourse-cdn.com/v4/letter/k/a587f6/32.png) [@kbourne](https://discuss.circleci.com/u/kbourne)\
**Post date:** [January 14, 2016, 9:27pm UTC](https://discuss.circleci.com/t/android-challenges-and-circle-yml-file/1552/1 "2016-01-14T21:27:07Z")

</div>

I am finding it challenging to set Android up on CircleCI. There doesn’t seem to be a well documented way to set up the circle.yml file specifically for Android that allows me to step through and add the functionality I need to address. Most examples out there fail in one way or another. My circle.yml looks like this:

> machine:  
> environment:  
> ANDROID\_HOME: /home/ubuntu/android  
> java:  
> version: oraclejdk8

> dependencies:  
> cache\_directories:  
> - ~/.android  
> - ~/android  
> override:  
> - (echo “Downloading Android SDK v19 now!”)  
> - source scripts/environmentSetup.sh && getAndroidSDK

> test:  
> pre:  
> - $ANDROID\_HOME/tools/emulator -avd testAVD -no-skin -no-audio -no-window  
> - ./gradlew clean assembleDebug  
> - ./gradlew assembleDebugTest  
> - source scripts/environmentSetup.sh && waitForAVD  
> override:  
> - (echo “Running JUnit tests!”)  
> - ./gradlew connectedAndroidTest

This is the environmentSetup.sh file referenced:

> #!/bin/bash

> # Fix the CircleCI path  
> function getAndroidSDK(){  
> export PATH=“$ANDROID\_HOME/platform-tools:$ANDROID\_HOME/tools:$PATH”

> DEPS=“$ANDROID\_HOME/installed-dependencies”

> if [! -e $DEPS]; then  
> cp -r /usr/local/android-sdk-linux $ANDROID\_HOME &&  
> echo y | android update sdk -u -a -t android-19 &&  
> echo y | android update sdk -u -a -t platform-tools &&  
> echo y | android update sdk -u -a -t build-tools-21.1.2 &&  
> echo y | android update sdk -u -a -t sys-img-x86-android-19 &&  
> #echo y | android update sdk -u -a -t addon-google\_apis-google-18 &&  
> echo no | android create avd -n testAVD -f -t android-19 --abi default/x86 &&  
> touch $DEPS  
> fi  
> }

> function waitForAVD {  
> (  
> local bootanim=“”  
> export PATH=$(dirname $(dirname $(which android)))/platform-tools:$PATH  
> until [[“$bootanim” =~ “stopped”]]; do  
> sleep 5  
> bootanim=$(adb -e shell getprop init.svc.bootanim 2\>&1)  
> echo “emulator status=$bootanim”  
> done  
> )  
> }

These are the errors I get:

> Line: $ $ANDROID\_HOME/tools/emulator -avd testAVD -no-skin -no-audio -no-window  
> Error message:  
> emulator: ERROR: x86 emulation currently requires hardware acceleration!  
> Ple ase ensure KVM is properly installed and usable.

> CPU acceleration status: KVM is not installed on this machine (/dev/kvm is missing). $ANDROID\_HOME/tools/emulator -avd testAVD -no-skin -no-audio -no-window returned exit code 1

> Line: $ ./gradlew clean assembleDebug  
> Error message:  
> Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain ./gradlew clean assembleDebug returned exit code 1

> Line: $ ./gradlew assembleDebugTest  
> Error message:  
> Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain ./gradlew assembleDebugTest returned exit code 1

There is a gradlew file in the root directory of the app on github.

---

<div class="post-metadata">

**Author:** ![PrabhatPandey](https://avatars.discourse-cdn.com/v4/letter/p/97f17d/32.png) [@PrabhatPandey](https://discuss.circleci.com/u/PrabhatPandey)\
**Post date:** [January 15, 2016, 7:11am UTC](https://discuss.circleci.com/t/android-challenges-and-circle-yml-file/1552/2 "2016-01-15T07:11:01Z")

</div>

They have specified in the docs that "One important note: it’s not possible to emulate Android on x86 or x86\_64 on our build containers. The Android emulator requires KVM on Linux, and we can’t provide it. So you might want to create the avd with --abi default/armeabi-v7a

"

---

<div class="post-metadata">

**Author:** ![kbourne](https://avatars.discourse-cdn.com/v4/letter/k/a587f6/32.png) [@kbourne](https://discuss.circleci.com/u/kbourne)\
**Post date:** [January 15, 2016, 4:43pm UTC](https://discuss.circleci.com/t/android-challenges-and-circle-yml-file/1552/3 "2016-01-15T16:43:41Z")

</div>

Thanks for that note PrabhatPandey. I dug into that documentation you referred to ([https://circleci.com/docs/android](https://circleci.com/docs/android)). I change the emulator configuration, doing away with the separate script altogether. I’m also trying a different dependency script. So now my circle.yml file looks like this, but now failing at the gradle dependencies:

> machine:  
> environment:  
> ANDROID\_HOME: /home/ubuntu/android  
> GRADLE\_OPTS: ‘-Dorg.gradle.jvmargs=“-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError”’  
> java:  
> version: oraclejdk8

> dependencies:  
> pre:  
> - echo y | android update sdk --no-ui --all --filter “platform-tools”  
> - echo y | android update sdk --no-ui --all --filter “android-23”  
> - echo y | android update sdk --no-ui --all --filter “build-tools-23.0.2”

> test:  
> override:  
> # start the emulator  
> - emulator -avd circleci-android22 -no-audio -no-window:  
> background: true  
> # wait for it to have booted  
> - circle-android wait-for-boot  
> # unlock the emulator screen  
> - sleep 30  
> # run build  
> - ./gradlew assembleDebug  
> # run tests against the emulator.  
> - ./gradlew connectedAndroidTest -PdisablePreDex  
> # copy the build outputs to artifacts  
> - cp -r app/build/outputs $CIRCLE\_ARTIFACTS  
> # copy the test results to the test results directory.  
> - cp -r app/build/outputs/androidTest-results/\* $CIRCLE\_TEST\_REPORTS

I get the error under dependencies:

> gradle dependencies  
> export TERM=“dumb”  
> if [-e ./gradlew]; then ./gradlew dependencies;else gradle dependencies;fi  
> returned exit code 1  
> Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain Action failed: gradle dependencies

According to the documentation, they load ./gradlew dependencies automatically if there is a Gradle wrapper checked in to the root of the repository. It seems like something is going wrong when this happens. Maybe I shouldn’t include gradlew in the build root (could gitignore it)? Or maybe it has a problem with one or more of the dependencies? Or maybe I need to add an additional line to the circle.yml dependencies? Can’t find CircleCI documentation on this, so basically just playing the guessing game and coming up short. Here is the gradle dependencies for reference:

dependencies {  
compile fileTree(dir: ‘libs’, include: [‘\*.jar’])  
testCompile ‘junit:junit:4.12’  
compile ‘com.android.support:appcompat-v7:23.1.1’  
compile ‘com.android.support:design:23.1.1’  
compile ‘com.android.support:support-v4:23.1.1’  
}

Any ideas what needs to be done?

---

<div class="post-metadata">

**Author:** ![kimh](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/kimh/32/19_2.png) [@kimh](https://discuss.circleci.com/u/kimh)\
**Post date:** [January 19, 2016, 6:38am UTC](https://discuss.circleci.com/t/android-challenges-and-circle-yml-file/1552/4 "2016-01-19T06:38:41Z")

</div>

@kbourne [This](http://stackoverflow.com/questions/29805622/could-not-find-or-load-main-class-org-gradle-wrapper-gradlewrappermain) SO questions looks like the exactly the same issue as yours.

Do you checkin your gradle wrapper scripts to Github?

---

<div class="post-metadata">

**Author:** ![Cedrick](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@Cedrick](https://discuss.circleci.com/u/Cedrick)\
**Post date:** [March 21, 2016, 11:57am UTC](https://discuss.circleci.com/t/android-challenges-and-circle-yml-file/1552/5 "2016-03-21T11:57:44Z")

</div>

@kimh Should I checkin all the /gradle/wrapper/ directory into git or only /gradle/wrapper/gradle-wrapper.propoerties ?

---

<div class="post-metadata">

**Author:** ![Cedrick](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@Cedrick](https://discuss.circleci.com/u/Cedrick)\
**Post date:** [March 21, 2016, 2:18pm UTC](https://discuss.circleci.com/t/android-challenges-and-circle-yml-file/1552/6 "2016-03-21T14:18:36Z")

</div>

Ok I got my anwser from gradle web site [Gradle wrapper](https://docs.gradle.org/current/userguide/gradle_wrapper.html)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [June 18, 2018, 11:33am UTC](https://discuss.circleci.com/t/android-challenges-and-circle-yml-file/1552/7 "2018-06-18T11:33:22Z")

</div>

Closed on June 18, 2018, 11:33am UTC


