qiujiayu / maven-android-plugin

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

start/stop emulator (headless) from plugin #4

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It would be nice to be able to start and stop an emulator from the
maven-android-plugin. Then it could be automatically started/stopped
before/after the platform tests.

What version of maven-android-plugin are you using?
2.0.0-SNAPSHOT as of 2009-06-07.

What is the output of "mvn -version" on your machine?
Maven version: 2.0.10
Java version: 1.6.0_13
OS name: "linux" version: "2.6.28-11-generic" arch: "i386" Family: "unix"

Original issue reported on code.google.com by hugo.josefson.old@gmail.com on 7 Jun 2009 at 8:34

GoogleCodeExporter commented 9 years ago
Implementation note:
find a good way of launching a background process, and then taking it down in 
another
goal/phase. see if cargo plugin runs a detached process like this, with for 
example
tomcat.

Original comment by hugo.josefson.old@gmail.com on 7 Jun 2009 at 8:36

GoogleCodeExporter commented 9 years ago

Original comment by hugo.josefson.old@gmail.com on 7 Jun 2009 at 9:45

GoogleCodeExporter commented 9 years ago
Implementation note:
Look at how Charlie Collins did it in android-maven (also Apache License 2.0):

http://code.google.com/p/android-maven/source/browse/#svn/android-maven-
plugin/trunk/src/main/java/com/totsp/mavenplugin/android

Original comment by hugo.josefson.old@gmail.com on 14 Jun 2009 at 9:10

GoogleCodeExporter commented 9 years ago
Is there a chance of getting this moved from Low to a higher priority? This is 
the
only thing now preventing running continuous builds of our portable and Android 
code.

Original comment by jameslee...@gmail.com on 8 Dec 2009 at 5:04

GoogleCodeExporter commented 9 years ago
Done. Thanks for bringing it up.

I have started by sending a request to Charlie Collins to learn what's happened 
to
his project. (the link in my Comment 3 above is dead)

/Hugo

Original comment by hugo.josefson.old@gmail.com on 17 Dec 2009 at 8:23

GoogleCodeExporter commented 9 years ago
I undeleted the project so you can take a look there. I had deleted it on 
Google Code 
so as not to confuse people and get in the way of this project. 

Basically I just have a ProcessWatcher and script mojos that run it from the 
command 
line. Not the most elegant way but simple, but back then it worked. Might be a 
more 
programmatic way, not sure. 

Also, you might want to look at the more robust Maven way to launch and 
external 
process, if that is what is needed (see JavaCommand in here, which uses plexus 
Commandline stuff):

http://mojo.codehaus.org/gwt-maven-
plugin/xref/org/codehaus/mojo/gwt/shell/AbstractGwtShellMojo.html

Original comment by charlie....@gmail.com on 17 Dec 2009 at 8:37

GoogleCodeExporter commented 9 years ago
Hi Charlie,

That was quick :)

Thanks!

You can close android-maven again if you like, because I have now copied its
subversion repo to an archive at github:
http://github.com/hugojosefson/OLD-ARCHIVED-android-maven

(I hope that's alright. Let me know otherwise.)

It was interesting to see the example from gwt-maven-plugin too. I like to work 
like
that myself; remembering some plugin I've seen which does something similar to 
what I
want, and then doing like they do.

In case you are in the mood, and have the time to spare, you are quite welcome 
to
take a stab at implementing something around this... Even if it would just be a
standalone main class running the emulator in a controlled way :)

Again, thanks.
/Hugo

Original comment by hugo.josefson.old@gmail.com on 17 Dec 2009 at 9:01

GoogleCodeExporter commented 9 years ago
Implementation note: I recall that the emulator listens to one more port when it
starts, which you can connect with a TCP socket to. You can give it simple text
commands through there, and that is probably the nicest way to tell it to shut 
down,
rather than just killing off the process.

Original comment by hugo.josefson.old@gmail.com on 17 Dec 2009 at 9:03

GoogleCodeExporter commented 9 years ago
Also, just noticed this evening that you already have a nice "CommandExecutor" 
- could 
use that. 

http://github.com/jayway/maven-android-
plugin/blob/master/src/main/java/com/jayway/maven/plugins/android/CommandExecuto
r.java

Original comment by charlie....@gmail.com on 18 Dec 2009 at 12:01

GoogleCodeExporter commented 9 years ago
I have emulator starting implemented in my github branch. I will clean things 
up with 
Hugo and implement stopping hopefully and then we will get it into the next 
release 
hopefully.

Original comment by mosa...@gmail.com on 10 Feb 2010 at 10:45

GoogleCodeExporter commented 9 years ago
implemented stopping and starting now in my github branch. Only for nix for 
now. Need 
some help with windows scripting. Hopefully all is good and hugo can pull this 
up. 

Original comment by mosa...@gmail.com on 15 Feb 2010 at 9:49

GoogleCodeExporter commented 9 years ago
Great! I pulled that in and released Maven Android Plugin 2.3.0. Let's keep 
this issue 
open for while longer, until "mvn android:emulator-stop" is supported in 
Windows too.

Original comment by hugo.josefson.old@gmail.com on 24 Feb 2010 at 12:21

GoogleCodeExporter commented 9 years ago

Original comment by hugo.josefson.old@gmail.com on 24 Feb 2010 at 12:22

GoogleCodeExporter commented 9 years ago
I have added another patch for the plugin to work on macos under certain 
configurations with launchd. I think we should maybe just release the new 
version as 
2.3.1 and get people to test the windows support from it. We could maybe 
announce on 
the maven users and dev lists (I can do that), but we have to get the barrier 
for testing 
low, which is why I vote for just releasing it. Worst case it doesnt work, 
which is just like 
now, but with some luck it works.. 

Original comment by mosa...@gmail.com on 12 Mar 2010 at 6:00

GoogleCodeExporter commented 9 years ago
INSTRUCTIONS FOR ANYONE TO TEST ON WINDOWS:

1. Set environment variable ANDROID_HOME to where you installed the Android SDK.
2. Run the Android AVD manager (by clicking the cell phone button in Eclipse, 
or by running 
the command 'android' in the Android SDK tools directory.)
3. Create an AVD named 'Default'.
4. Run these commands:

mvn 
com.jayway.maven.plugins.android.generation2:maven-android-plugin:emulator-start
mvn 
com.jayway.maven.plugins.android.generation2:maven-android-plugin:emulator-stop

The first command should start the emulator.
The second command should kill it.

Please let us know if the first and/or second command(s) work or fail.

Thanks!

Original comment by hugo.josefson.old@gmail.com on 13 Mar 2010 at 5:09

GoogleCodeExporter commented 9 years ago
The emulator-start goal fails on Windows.

The command window has:

[INFO] ------------------------------------------------------------------------
[INFO] Building All jimandlisa.com Projects
[INFO]    task-segment:
[com.jayway.maven.plugins.android.generation2:maven-android-plugin:emulator-
start] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [android:emulator-start {execution: default-cli}]
[INFO] Android emulator command: C:\devjim\tools\android/tools/emulator -avd 
Default
unknown
[INFO] Starting android emulator with script:
C:\DOCUME~1\Jim\LOCALS~1\Temp\\maven-android-plugin-em
ulator-start.bat

C:\devjim\projects\trunk\All>START MavenAndroidPlugin-AVDDefault
C:\devjim\tools\android/tools/emula
tor -avd Default

This results in a Windows modal dialog with the title
"MavenAndroidPlugin-AVDDefault", and the message "Windows cannot find
'MavenAndroidPlugin-AVDDefault'. Make sure you typed the name correctly, and 
then try
again. To search for a file, click the Start button, and then click Search."

Clicking OK on the dialog causes this to display in the command window:

C:\devjim\projects\trunk\All>START MavenAndroidPlugin-AVDDefault
C:\devjim\tools\android/tools/emula
tor -avd Default
[ERROR] The system cannot find the file MavenAndroidPlugin-AVDDefault.

C:\devjim\projects\trunk\All>FOR /F "tokens=2" %I in ('TASKLIST /NH /FI 
"WINDOWTITLE
eq MavenAndroid
Plugin-AVDDefault"') DO SET PID=%I
[ERROR] INFO: No tasks running with the specified criteria.

C:\devjim\projects\trunk\All>ECHO  
1>C:\DOCUME~1\Jim\LOCALS~1\Temp\/maven-android-plugin-emulator.p
id
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO]

Embedded error: ANDROID-040-001: Could not execute: Command = cmd.exe /X /C
"C:\DOCUME~1\Jim\LOCALS~
1\Temp\\maven-android-plugin-emulator-start.bat", Result = 0
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7 minutes 28 seconds
[INFO] Finished at: Sun Mar 21 13:15:38 PDT 2010
[INFO] Final Memory: 29M/254M
[INFO] ------------------------------------------------------------------------
C:\devjim\projects\trunk\All>

The emulator-stop goal fails with:

[INFO]    task-segment:
[com.jayway.maven.plugins.android.generation2:maven-android-plugin:emulator-
stop] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [android:emulator-stop {execution: default-cli}]
[INFO] Stopping android emulator with pid: ECHO is on.
[ERROR] ERROR: Invalid Syntax. Specify valid numeric value for '/PID' option.
[ERROR] Type "TASKKILL /?" for usage.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO]

Embedded error: ANDROID-040-001: Could not execute: Command = cmd.exe /X /C 
"TASKKILL
/PID "ECHO is
on."", Result = 1
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9 seconds
[INFO] Finished at: Sun Mar 21 13:18:51 PDT 2010
[INFO] Final Memory: 25M/254M
[INFO] ------------------------------------------------------------------------
C:\devjim\projects\trunk\All>

Original comment by jameslee...@gmail.com on 21 Mar 2010 at 8:19

GoogleCodeExporter commented 9 years ago
First - could you post the contents of the file 
C:\DOCUME~1\Jim\LOCALS~1\Temp\\maven-android-plugin-emulator-start.bat

Second - could you try starting the emualtor with the command 
C:\devjim\tools\android/tools/emulator -avd Default

Third try the command 
START MavenAndroidPlugin-AVDDefault C:\devjim\tools\android/tools/emulator -
avd Default

If the first two work the third is probably the problem. If that is the case 
make a bat 
file with the command from second called test.bat and try
START MavenAndroidPlugin-AVDDefault test.bat

Stopping most likely only fails because starting did not work since it relies 
on a .pid 
file that never got created.. 

Original comment by mosa...@gmail.com on 24 Mar 2010 at 6:11

GoogleCodeExporter commented 9 years ago
I also fail at START MavenAndroidPlugin-AVDDefault 

This results in a Windows modal dialog with the title
"MavenAndroidPlugin-AVDDefault", and the message "Windows cannot find
'MavenAndroidPlugin-AVDDefault'. Make sure you typed the name correctly, and 
then try
again. To search for a file, click the Start button, and then click Search."

Where does MavenAndroidPlugin-AVDDefault come from?

Original comment by mikenere...@gmail.com on 15 Apr 2010 at 7:46

GoogleCodeExporter commented 9 years ago
If you do not specifi the avd in the emulator config in the pom file you the 
plugin will try to start an emualtor 
named "Default". You have to mamuallry created that with the avd manager. On 
windows it might still not work. I 
have no access to a windows machine and can not debug it.  Somebody needs to 
follow the steps I documented 
above and send me the results or debug themselves.. 

Original comment by mosa...@gmail.com on 16 Apr 2010 at 5:24

GoogleCodeExporter commented 9 years ago
The .bat has:

START MavenAndroidPlugin-AVDDefault C:\devjim\tools\android/tools/emulator -avd 
Default 
FOR /F "tokens=2" %%I in ('TASKLIST /NH /FI "WINDOWTITLE eq
MavenAndroidPlugin-AVDDefault"' ) DO SET PID=%%I
ECHO %PID% > C:\DOCUME~1\Jim\LOCALS~1\Temp\/maven-android-plugin-emulator.pid

The .pid file exists.

Original comment by jameslee...@gmail.com on 23 May 2010 at 6:20

GoogleCodeExporter commented 9 years ago
Running the START command by hand brings up the same modal error dialog.

Original comment by jameslee...@gmail.com on 23 May 2010 at 6:43

GoogleCodeExporter commented 9 years ago
Can you try to change and see if the second part of the first line: 

C:\devjim\tools\android/tools/emulator -avd Default 

works. If so, please check if adding start at the front works as well .. 

START C:\devjim\tools\android/tools/emulator -avd Default 

and also try adding double quotes around the windowtitle like so
START "MavenAndroidPlugin-AVDDefault" C:\devjim\tools\android/tools/emulator 
-avd Default 

If that works with the quotes edit the whole script by adding the quotes and 
then run it.  Once thats is 
fine.. confirm that the number (process id) in the file is the same as the one 
of the emultor (using some 
sort of taskmanager or so).

If the pid is fine. Try running the emulator stop command and see if that 
works: 

mvn android:emulator-stop

If anything goes wrong along the lines... put the output in a comment here.  
Thanks a lot ...

Original comment by mosa...@gmail.com on 25 May 2010 at 4:23

GoogleCodeExporter commented 9 years ago
Adding double quotes around "MavenAndroidPlugin-AVDDefault" in the generated 
.bat
works fine. The emulator launches correctly.

Shut down does not work, despite the PID being correct. The error is:

C:\Documents and Settings\Jim\Local Settings\Temp>mvn android:emulator-stop
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'android'.
[INFO] com.jayway.maven.plugins.android.generation2: checking for updates from
oss.sonatype.org-jayw
ay-releases
[INFO] com.jayway.maven.plugins.android.generation2: checking for updates from
snapshot.codehaus.org

[INFO] org.apache.maven.plugins: checking for updates from
oss.sonatype.org-jayway-releases
[INFO] org.apache.maven.plugins: checking for updates from snapshot.codehaus.org
[INFO] org.codehaus.mojo: checking for updates from 
oss.sonatype.org-jayway-releases
[INFO] org.codehaus.mojo: checking for updates from snapshot.codehaus.org
[INFO] artifact 
com.jayway.maven.plugins.android.generation2:maven-android-plugin:
checking for upda
tes from oss.sonatype.org-jayway-releases
[INFO] artifact 
com.jayway.maven.plugins.android.generation2:maven-android-plugin:
checking for upda
tes from snapshot.codehaus.org
Downloading:
http://oss.sonatype.org/content/repositories/jayway-releases/com/jayway/maven/pl
ugins/a
ndroid/generation2/maven-android-plugin/2.4.0/maven-android-plugin-2.4.0.pom

Downloading:
http://oss.sonatype.org/content/repositories/jayway-releases/com/jayway/maven/pl
ugins/a
ndroid/generation2/maven-android-plugin/2.4.0/maven-android-plugin-2.4.0.jar
68K downloaded  (maven-android-plugin-2.4.0.jar)
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO]    task-segment: [android:emulator-stop] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [android:emulator-stop {execution: default-cli}]
[INFO] Stopping android emulator with pid: 948
[ERROR] ERROR: Invalid Syntax. Specify valid numeric value for '/PID' option.
[ERROR] Type "TASKKILL /?" for usage.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO]

Embedded error: ANDROID-040-001: Could not execute: Command = cmd.exe /X /C 
"TASKKILL
/PID "948 "",
Result = 1
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 24 seconds
[INFO] Finished at: Tue May 25 19:22:18 PDT 2010
[INFO] Final Memory: 25M/254M
[INFO] ------------------------------------------------------------------------
C:\Documents and Settings\Jim\Local Settings\Temp>

Original comment by jameslee...@gmail.com on 26 May 2010 at 2:25

GoogleCodeExporter commented 9 years ago
Shutdown will work once the Maven plugin generates a slightly different 
TASKKILL command:

C:\Documents and Settings\Jim\Local Settings\Temp>cmd.exe /X /C "TASKKILL /PID 
948"
SUCCESS: The process with PID 948 has been terminated.

Original comment by jameslee...@gmail.com on 26 May 2010 at 2:27

GoogleCodeExporter commented 9 years ago
Okay.. I have committed fixes to my github branch. Ideally you could download 
and build it and test it out. 
Download from
http://github.com/mosabua/maven-android-plugin

Then build with 
mvn clean install

and up the version of the plugin in your test project to 2.4.1-SNAPSHOT and you 
should be ready to go. 
Fingers crossed and let me know how it goes.

Original comment by mosa...@gmail.com on 26 May 2010 at 6:16

GoogleCodeExporter commented 9 years ago
Skipping tests, it builds. Running mvn
com.jayway.maven.plugins.android.generation2:maven-android-plugin:emulator-start
, it
starts the emulator, but the build window hangs at:

[INFO] [android:emulator-start {execution: default-cli}]
[INFO] Android emulator command: C:\devjim\tools\android/tools/emulator -avd 
Default
unknown
[INFO] Starting android emulator with script:
C:\DOCUME~1\Jim\LOCALS~1\Temp\\maven-android-plugin-em
ulator-start.bat

C:\zzz>START "MavenAndroidPlugin-AVDDefault"  C:\devjim\tools\android/tools/emu
lator -avd Default

C:\zzz>FOR /F "tokens=2" %I in ('TASKLIST /NH /FI "WINDOWTITLE eq MavenAndroidP
lugin-AVDDefault"') DO SET PID=%I

C:\zzz>SET PID=428

C:\zzz>ECHO 428  1>C:\DOCUME~1\Jim\LOCALS~1\Temp\/maven-android-plugin-emulator
.pid

Is it supposed to block, or keep going? If block, then it's working.

In a separate window, running mvn
com.jayway.maven.plugins.android.generation2:maven-android-plugin:emulator-stop 
did
not work:

[INFO] Stopping android emulator with pid: 428
[ERROR] ERROR: Invalid Argument/Option - '/PID 428 '.
[ERROR] Type "TASKKILL /?" for usage.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO]

Embedded error: ANDROID-040-001: Could not execute: Command = cmd.exe /X /C 
"TASKKILL
"/PID 428 "",
 Result = 1
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8 seconds
[INFO] Finished at: Sat May 29 12:46:46 PDT 2010
[INFO] Final Memory: 28M/254M
[INFO] ------------------------------------------------------------------------

When the emulator was stopped manually, the blocked output resumed and 
displayed:

[INFO] Waiting for emulator start:5000

Original comment by jameslee...@gmail.com on 31 May 2010 at 4:18

GoogleCodeExporter commented 9 years ago
Thanks... I will have to take a look at this some more later. It is supposed to 
keep going .. and the emulator 
stop is supposed to leave out the apostrophes... darn. 

Original comment by mosa...@gmail.com on 1 Jun 2010 at 5:07

GoogleCodeExporter commented 9 years ago
You need to specify the /separate arg after the start command:

START /separate "MavenAndroidPlugin-AVDDefault" 
C:\devjim\tools\android/tools/emulator -avd Default

Original comment by jameslee...@gmail.com on 17 Jun 2010 at 5:09

GoogleCodeExporter commented 9 years ago
I have added that to the command line now. Can you retry? 

Original comment by mosa...@gmail.com on 17 Jun 2010 at 4:34

GoogleCodeExporter commented 9 years ago
What's the status at the moment? With maven-android-plugin 2.5.2 
android:emulator-start is still blocking.

Original comment by mserv...@gmail.com on 26 Aug 2010 at 12:45

GoogleCodeExporter commented 9 years ago
What is the command line in the script ? Looking at the code the command line 
produced should be as above, but I have no way of verifying. No windows machine 
or vm available...  if somebody could step up and debug this with windows so a 
valid start script is created that would be great. Neither Hugo nor myself have 
any Windows around.. 

Can you check if the script on its own works? 

Original comment by mosa...@gmail.com on 26 Aug 2010 at 4:15

GoogleCodeExporter commented 9 years ago
patch attached
fixes - emulator cannot be stopped on windows because of command params not set
correctly in the stop command, also makes sure to start the emulator when the 
device is
connected to the usb, by passing the -e option to adb when getting the serial 
number.

Original comment by cspeche...@gmail.com on 27 Aug 2010 at 6:45

Attachments:

GoogleCodeExporter commented 9 years ago
This works on windows 7, not sure of other flavors.
The following issue is still present, after starting the emulator, you have to 
Ctrl+C to quit the batch file.

Original comment by cspeche...@gmail.com on 27 Aug 2010 at 6:49

GoogleCodeExporter commented 9 years ago
So would it be possible to launch the script into the background somehow or 
make it exist by adding something to the script? 

Original comment by mosa...@gmail.com on 27 Aug 2010 at 5:35

GoogleCodeExporter commented 9 years ago
Also in your patch you are separating the pid into separate parameters. This 
caused issues with apostrophes in the past.. weird. But since it is working for 
you... I will apply this patch tonight.. maybe you can find a solution for the 
backgrounding/exiting. Does adding & not work? 

Original comment by mosa...@gmail.com on 27 Aug 2010 at 5:37

GoogleCodeExporter commented 9 years ago
I pushed the patch into my github clone and made a pull request.

Original comment by mosa...@gmail.com on 27 Aug 2010 at 6:03

GoogleCodeExporter commented 9 years ago
I released maven-android-plugin 2.6.0 with that patch in it. Is this issue 
resolved?

Original comment by hugo.josefson.old@gmail.com on 26 Sep 2010 at 7:13

GoogleCodeExporter commented 9 years ago
Good question... some windows users need to confirm...

Original comment by mosa...@gmail.com on 3 Oct 2010 at 4:30

GoogleCodeExporter commented 9 years ago
When I call mvn android:emulator-start on windows 7 64bit the emulator starts 
but hangs the command line. The output is as follows.

C:\dev\workspaces\eclipse-SDK-3.5.2-win32\Foo>mvn android:emulator
-start
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Market Risk Android
[INFO]    task-segment: [android:emulator-start] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [android:emulator-start {execution: default-cli}]
[INFO] Android emulator command: C:\dev\tools\android-sdk-windows/tools/emulator
 -avd FooAvd
unknown
[INFO] Starting android emulator with script: C:\Users\dhruba\AppData\Local\Temp
\\maven-android-plugin-emulator-start.bat

C:\dev\workspaces\eclipse-SDK-3.5.2-win32\Foo>START /separate "Mav
enAndroidPlugin-AVDFooAvd"  C:\dev\tools\android-sdk-windows/tools
/emulator -avd FooAvd

C:\dev\workspaces\eclipse-SDK-3.5.2-win32\Foo>FOR /F "tokens=2" %I
 in ('TASKLIST /NH /FI "WINDOWTITLE eq MavenAndroidPlugin-AVDFooAv
d"') DO SET PID=%I

C:\dev\workspaces\eclipse-SDK-3.5.2-win32\Foo>SET PID=5180

C:\dev\workspaces\eclipse-SDK-3.5.2-win32\Foo>ECHO 5180  1>C:\User
s\dhruba\AppData\Local\Temp\/maven-android-plugin-emulator.pid

At this point it hangs until the emulator has been manually closed. Once closed 
it releases maven and it carries on as follows.

[INFO] Waiting for emulator start:6000
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 minute 41 seconds
[INFO] Finished at: Sat Nov 06 18:26:29 GMT 2010
[INFO] Final Memory: 18M/45M
[INFO] ------------------------------------------------------------------------

The output of the script 
(C:\Users\foo\AppData\Local\Temp\\maven-android-plugin-emulator-start.bat) is 
as follows.

START /separate "MavenAndroidPlugin-AVDMarketRiskAndroidAvd"  
C:\dev\tools\android-sdk-windows/tools/emulator -avd MarketRiskAndroidAvd 
FOR /F "tokens=2" %%I in ('TASKLIST /NH /FI "WINDOWTITLE eq 
MavenAndroidPlugin-AVDMarketRiskAndroidAvd"' ) DO SET PID=%%I
ECHO %PID% > 
C:\Users\dhruba\AppData\Local\Temp\/maven-android-plugin-emulator.pid

The script clearly has "START /separate" but that doesn't work. Is there any 
way to start this in the background?

Many thanks.

Original comment by bdhr...@msn.com on 6 Nov 2010 at 6:29

GoogleCodeExporter commented 9 years ago
So if I understand correctly it gets the right PID and the emulator is starting 
up but the command ECHO %PID% > ... does not hang up. Can you check out if the 
pid file has the right number in it (5180) And can you check if the script runs 
on its own and exits?

Original comment by mosa...@gmail.com on 7 Nov 2010 at 6:27

GoogleCodeExporter commented 9 years ago
Thanks for getting back to me. Yes the pid file has the right number in it each 
time (although there is a new line after the PID). Also the script runs on its 
own and does exit. I noticed one other thing though. When I run mvn 
android:emulator-start and all the dos windows pop up one of them has an error 
that comes up and goes away very quickly. I've managed to screenshot it after 
several failed attempts. It is attached. I'm not sure if it will have any 
relation to this problem. In conclusion the dos prompt still hangs and the wait 
time is only applied after the emulator is closed.

Original comment by bdhr...@msn.com on 7 Nov 2010 at 9:23

Attachments:

GoogleCodeExporter commented 9 years ago
Sorry I had to delete the previous attachment. I've uploaded a new one.

Original comment by bdhr...@msn.com on 7 Nov 2010 at 9:25

Attachments:

GoogleCodeExporter commented 9 years ago
Whoa.. I have no idea what that one is nor how it could happen.

Original comment by mosa...@gmail.com on 8 Nov 2010 at 5:59

GoogleCodeExporter commented 9 years ago
well, the emulator-stop is not yet working as you can see on the error log 
below.
seems like there is two extra quotes around the PID.
btw, I am using windows xp and the version 2.8.3

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building HelloFlashlight 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-android-plugin:2.8.3:emulator-stop (default-cli) @ 
helloflashlight ---
[INFO] Stopping android emulator with pid: 6248 
[INFO] ERROR: Invalid Syntax. Specify valid numeric value for '/PID' option.
[INFO] Type "TASKKILL /?" for usage.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.469s
[INFO] Finished at: Thu Dec 30 08:23:58 BRST 2010
[INFO] Final Memory: 4M/8M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal 
com.jayway.maven.plugins.android.generation2:maven-android-plugin:2.8.3:emulator
-stop (default-cli) on project helloflashlight: MojoExecutionException: 
ANDROID-040-001: Could not execute: Command = cmd.exe /X /C "TASKKILL /PID 
"6248 "", Result = 1 -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e 
switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please 
read the following articles:
[ERROR] [Help 1] 
http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Original comment by thiagoca...@gmail.com on 30 Dec 2010 at 10:29

GoogleCodeExporter commented 9 years ago
Could you try patching and fixing it under windows yourself? I have no way of 
testing it since I have no windows around here..  all you would have to do is 
change the method stopEmulatorWindows in the AbstractEmulatorMojo. I am a bit 
confused though since it seems to be working on windows 7 for some users... 

Original comment by mosa...@gmail.com on 30 Dec 2010 at 4:47

GoogleCodeExporter commented 9 years ago
hi, 
i am also having this problem on win7 64-bit. is the issue resolved? if not, is 
there any workaround??

Original comment by duo.ska...@gmail.com on 28 Jan 2011 at 8:24

GoogleCodeExporter commented 9 years ago
The windows users will have to find a windows developer that can help them out. 
I cant as stated many times before.

Original comment by mosa...@gmail.com on 29 Jan 2011 at 5:39

GoogleCodeExporter commented 9 years ago
I want to fix this issue. But can anyone help me get the source code.
I am getting the following error when i try to download the source from command 
line
==================================================================
$ git clone git://github.com/jayway/maven-android-plugin.git
Cloning into maven-android-plugin...
github.com[0: 207.97.227.239]: errno=Invalid argument
fatal: unable to connect a socket (Invalid argument)
================================================================
Its not even working form elcipse GIT plugin.

Original comment by kkba...@gmail.com on 18 Feb 2011 at 9:56

GoogleCodeExporter commented 9 years ago
Looks like a local network issue. Do other git repos work? The command is 
correct and works for me.. also check your git version maybe.

Original comment by mosa...@gmail.com on 18 Feb 2011 at 10:52

GoogleCodeExporter commented 9 years ago
WIN XP x64 I found emulator-start worked;  emulator-stop failed.  See below
E:\Android_Samples\jayway-maven-android-plugin-samples-08bd019\helloflashlight>m
vn com.jayway.maven.plugins.android.generation2:maven-androi
d-plugin:emulator-stop
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building HelloFlashlight
[INFO]    task-segment: 
[com.jayway.maven.plugins.android.generation2:maven-android-plugin:emulator-stop
] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [android:emulator-stop {execution: default-cli}]
[INFO] Stopping android emulator with pid: No
[INFO] ERROR: The process "No " not found.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO]

Embedded error: ANDROID-040-001: Could not execute: Command = cmd.exe /X /C 
"TASKKILL /PID "No "", Result = 128
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10 seconds
[INFO] Finished at: Sun Jun 05 20:27:56 EDT 2011
[INFO] Final Memory: 23M/194M
[INFO] ------------------------------------------------------------------------
E:\Android_Samples\jayway-maven-android-plugin-samples-08bd019\helloflashlight>

Original comment by Robt.W....@gmail.com on 6 Jun 2011 at 12:32