sajith4u / maven-android-plugin

Automatically exported from code.google.com/p/maven-android-plugin
0 stars 0 forks source link

Wait for emulator behaviour changed #421

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Configure the following settings:
<emulator>
  <avd>Android_4.3</avd>
  <wait>120000</wait>
</emulator>

2. Start instrumentation tests:
mvn verify

What is the expected output?
Maven starts the emulator, waits 2 minutes, and if the emulator is ready by 
then, continues. (As far as I can remember this was the behaviour in version 
3.5.3)

What do you see instead?
Maven starts the emulator, waits up to 2 minutes until it can connect via adb 
to the emulator and then immediatly! continues. This means sometimes the build 
continues after only 15 seconds instead of 2 minutes.

Since the Android OS has not finished booting by this time, the instrumentation 
crashes or fails (not reliable). Also the tests are not found.
If the emulator is given more time for startup, tests are found and executed 
successfully.

[INFO] Starting android emulator with script: 
C:\work\cygwin\tmp\\android-maven-plugin-emulator-start.vbs
[INFO] Waiting for emulator start:120000
[INFO] Emulator is up and running.
[INFO]
[INFO] --- android-maven-plugin:3.7.0:internal-pre-integration-test 
(default-internal-pre-integration-test) ---
[INFO] C:\work\tools\android-sdk\build-tools\18.0.1\aapt.exe
[INFO] Found 1 devices connected with the Android Debug Bridge
[INFO] android.device parameter set to Android_4.3
[INFO] emulator-5554_Android_4.3_unknown_google_sdk :   Successfully 
uninstalled testapp from emulator-5554_Android_4.3_unknown_google_sdk
[INFO] Found 1 devices connected with the Android Debug Bridge
[INFO] android.device parameter set to Android_4.3
[INFO] emulator-5554_Android_4.3_unknown_google_sdk :   Successfully installed 
C:\work\project\test.apk to emulator-5554_Android_4.3_unknown_google_sdk
[INFO]
[INFO] --- android-maven-plugin:3.7.0:internal-integration-test 
(default-internal-integration-test) ---
[INFO] Found 1 devices connected with the Android Debug Bridge
[INFO] android.device parameter set to Android_4.3
[INFO] emulator-5554_Android_4.3_unknown_google_sdk :   Running instrumentation 
tests in testapp
[INFO] emulator-5554_Android_4.3_unknown_google_sdk :     Run started: testapp, 
0 tests:
[INFO] emulator-5554_Android_4.3_unknown_google_sdk :     Run failed: 
Instrumentation run failed due to 'Process crashed.'
[INFO] emulator-5554_Android_4.3_unknown_google_sdk :     Run ended: 0 ms
[INFO]   Tests run: 0,  Failures: 0,  Errors: 0
[INFO] emulator-5554_Android_4.3_unknown_google_sdk :   Report file written to 
C:\work\project\TEST-emulator-5554_Android_4.3_unknown_google_sdk.xml

What version of maven-android-plugin are you using?
Tried 3.6.0, 3.6.1, 3.7.0, same behaviour

What are the complete output lines of "mvn -version" on your machine?
Apache Maven 3.0.4 (r1232337; 2012-01-17 09:44:56+0100)
Maven home: C:\work\tools\apache-maven-3.0.4
Java version: 1.7.0_25, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_25\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"

Please provide any additional information below.

Original issue reported on code.google.com by basskrap...@gmail.com on 8 Oct 2013 at 1:59

GoogleCodeExporter commented 9 years ago
Possibly related with Issue 362 and Issue 249.

Original comment by basskrap...@gmail.com on 8 Oct 2013 at 2:04

GoogleCodeExporter commented 9 years ago
Ok found it in the changelogs, this is a feature implemented in 3.5.1. Issue 270
So it behaves like specified but we need a additional waiting time to wait 
until the OS has booted. Is it possible to add a second parameter like 
"waitForBoot"?

Original comment by basskrap...@gmail.com on 8 Oct 2013 at 2:17

GoogleCodeExporter commented 9 years ago
This cause my tests fail too. Any idea about how to ask the Maven to wait until 
the emulator is ready?

Original comment by hqfk...@gmail.com on 26 Nov 2013 at 7:00

GoogleCodeExporter commented 9 years ago
I'm using a ant task as a workaround. After starting up the emulator, it just 
waits for a specified time until it starts the integration tests. 

Be careful to wait for the emulator before entering the pre-integration-test 
phase, it seems the instrumentation produces sporadic errors if the emulator is 
not booted up completly. 

<build>
    <plugins>
        <plugin>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <configuration>
                <!-- enable integration tests, these will be executed in the integration-test phase -->
                <testSkip>false</testSkip>
                <test>
                    <createReport>true</createReport>
                </test>
                <device>${android.avd}</device>
                <emulator>
                    <avd>${android.avd}</avd>
                    <wait>${android.avd.wait.startup}</wait>
                    <!-- http://developer.android.com/tools/help/emulator.html -->
                    <options>-noaudio -no-boot-anim -no-window -memory 512</options>
                </emulator>
            </configuration>
            <executions>
                <execution>
                    <id>startEmulator</id>
                    <phase>package</phase>
                    <goals>
                        <goal>emulator-start</goal>
                    </goals>
                </execution>
                <execution>
                    <id>stopEmulator</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>emulator-stop</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <!-- Workaround for android bootup. -->
        <!-- Ticket for this issue: http://code.google.com/p/maven-android-plugin/issues/detail?id=421 -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <configuration>
                <tasks>
                    <echo message="Sleeping ${android.avd.wait.boot}s to wait for Android bootup..."/>
                    <sleep seconds="${android.avd.wait.boot}"/>
                </tasks>
            </configuration>
            <executions>
                <execution>
                    <id>wait</id>
                    <phase>package</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Original comment by basskrap...@gmail.com on 27 Nov 2013 at 10:06

GoogleCodeExporter commented 9 years ago
Thanks for the workaround.  It successfully makes the maven wait the specified 
time. However, it appears that the unlock emulator in the emulator-start goal 
is not get executed.  I am using -Dandroid.emulatorUnlock=true to pass that 
boolean parameter in the maven command line.  Any idea?

Thanks again. And Happy Thanksgiving!

Original comment by hqfk...@gmail.com on 27 Nov 2013 at 3:07

GoogleCodeExporter commented 9 years ago
Sorry, no idea about unlocking the screen :(

Original comment by basskrap...@gmail.com on 27 Nov 2013 at 3:26

GoogleCodeExporter commented 9 years ago
We are no longer using the issue tracking system on Google Code. Please refile 
this issue on https://github.com/jayway/maven-android-plugin/issues if you 
still have this problem with the latest release of the Android Maven Plugin

Original comment by mosa...@gmail.com on 19 May 2014 at 4:20