[JIRA] (JENKINS-55313) Gradle support for connectedAndroidTest

11 views
Skip to first unread message

jenkins@attrib.org (JIRA)

unread,
Dec 22, 2018, 11:22:01 AM12/22/18
to jenkinsc...@googlegroups.com
Karl Fritsche created an issue
 
Jenkins / Bug JENKINS-55313
Gradle support for connectedAndroidTest
Issue Type: Bug Bug
Assignee: Christopher Orr
Components: android-emulator-plugin
Created: 2018-12-22 16:21
Environment: Android Emulator 3.0
Android build tools 28.0.3
Priority: Minor Minor
Reporter: Karl Fritsche

Currently I struggle to get the android emulator running in combination with gradle connectedAndroidTest 

The tests are working if I start the emulator manually.

Also in the log I see the emulator starts correctly, but I always get 

Execution failed for task ':app:connectedDebugAndroidTest'.
> com.android.builder.testing.api.DeviceException: No connected devices!

After a while of digging around I found out that the reason is that gradle uses the standard port of the adb to check for emulators and not the newly started from the android emulator plugin.

I checked using bash if ANDROID_SERIAL is correctly set (emulator-XXXX) and it is, but it seems connectedAndroidTest doesn't pickup the value and checks for that emulator.

I wonder if anybody has a hint what to check or how other people using this plugin starting the
connectedAndroidTests?

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

gaurav@dream11.com (JIRA)

unread,
Apr 14, 2020, 8:36:03 AM4/14/20
to jenkinsc...@googlegroups.com
Gaurav P commented on Bug JENKINS-55313
 
Re: Gradle support for connectedAndroidTest

I am also facing the same issue 
have you manage to solve it ?

This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo

jenkins@attrib.org (JIRA)

unread,
Apr 14, 2020, 10:49:04 AM4/14/20
to jenkinsc...@googlegroups.com

My current workaround is not using the plugin.
I use a shell script with the following content:

# doing android emulator stuff manual
$ANDROID_HOME/platform-tools/adb start-server
$ANDROID_HOME/emulator/emulator -prop persist.sys.language=de -prop persist.sys.country=DE -avd $AVD_IMAGE -no-window -no-audio &
EMULATOR_PID=$!

# Wait for Android to finish booting
WAIT_CMD="$ANDROID_HOME/platform-tools/adb wait-for-device shell getprop init.svc.bootanim"
until $WAIT_CMD | grep -m 1 stopped; do
  echo "Waiting..."
  sleep 1
done

[ -d build ] || mkdir build
$ANDROID_HOME/platform-tools/adb shell logcat -v time > build/logcat.log &
LOGCAT_PID=$!
$ANDROID_HOME/platform-tools/adb shell wm dismiss-keyguard
$ANDROID_HOME/platform-tools/adb shell input keyevent 4

# run tests
./gradlew --continue test lint connectedAndroidTest || echo "failed"

# Stop the background processes
kill $LOGCAT_PID
kill $EMULATOR_PID

Its not super stable and sometimes it fails and if I just rerun it, it works. Didn't figured out if it is because of the setup or because of a bad test on our side.

jenkins@attrib.org (JIRA)

unread,
Apr 14, 2020, 10:54:02 AM4/14/20
to jenkinsc...@googlegroups.com
Karl Fritsche edited a comment on Bug JENKINS-55313
My current workaround is not using the plugin.
I use a shell script with the following content:

{code}

# doing android emulator stuff manual
$ANDROID_HOME/platform-tools/adb start-server
$ANDROID_HOME/emulator/emulator -prop persist.sys.language=de -prop persist.sys.country=DE -avd $AVD_IMAGE -no-window -no-audio &
EMULATOR_PID=$!

# Wait for Android to finish booting
WAIT_CMD="$ANDROID_HOME/platform-tools/adb wait-for-device shell getprop init.svc.bootanim"
until $WAIT_CMD | grep -m 1 stopped; do
  echo "Waiting..."
  sleep 1
done

[ -d build ] || mkdir build
$ANDROID_HOME/platform-tools/adb shell logcat -v time > build/logcat.log &
LOGCAT_PID=$!
$ANDROID_HOME/platform-tools/adb shell wm dismiss-keyguard
$ANDROID_HOME/platform-tools/adb shell input keyevent 4

# run tests
./gradlew --continue test lint connectedAndroidTest || echo "failed"

# Stop the background processes
kill $LOGCAT_PID
kill $EMULATOR_PID
{code}


Its not super stable and sometimes it fails and if I just rerun it, it works. Didn't figured out if it is because of the setup or because of a bad test on our side.


ANDROID_HOME is a global envoirment variable and I have a second job which force updates all images, each week.

{code}
yes | $ANDROID_HOME/tools/bin/sdkmanager --update
$ANDROID_HOME/tools/bin/avdmanager delete avd -n pixel_23 || true
$ANDROID_HOME/tools/bin/avdmanager create avd -n pixel_23 -d pixel -k "system-images;android-23;default;x86" --force
$ANDROID_HOME/tools/bin/avdmanager delete avd -n pixel_24 || true
$ANDROID_HOME/tools/bin/avdmanager create avd -n pixel_24 -d pixel -k "system-images;android-24;default;x86" --force
$ANDROID_HOME/tools/bin/avdmanager delete avd -n pixel_26 || true
$ANDROID_HOME/tools/bin/avdmanager create avd -n pixel_26 -d pixel -k "system-images;android-26;default;x86_64" --force
$ANDROID_HOME/tools/bin/avdmanager delete avd -n pixel_28 || true
$ANDROID_HOME/tools/bin/avdmanager create avd -n pixel_28 -d pixel -k "system-images;android-28;default;x86" --force
$ANDROID_HOME/tools/bin/avdmanager delete avd -n nexus10_28 || true
$ANDROID_HOME/tools/bin/avdmanager create avd -n nexus10_28 -d "Nexus 10" -k "system-images;android-28;default;x86_64" --force
{code}

AVD_IMAGE is a select parameter for this job. I have a third job (matrix job), which then calls this job with all images.

gaurav@dream11.com (JIRA)

unread,
Apr 14, 2020, 11:04:05 AM4/14/20
to jenkinsc...@googlegroups.com

jenkins@attrib.org (JIRA)

unread,
Apr 14, 2020, 11:43:02 AM4/14/20
to jenkinsc...@googlegroups.com

If you find a better solution, feel free to update here

Reply all
Reply to author
Forward
0 new messages