Skip to content

Commit 68dd4e0

Browse files
committed
Use full path of emulator
1 parent b02535c commit 68dd4e0

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

src/processing/mode/android/AndroidMode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ public void handleRunEmulator(Sketch sketch, AndroidEditor editor,
298298
}
299299

300300
int comp = build.getAppComponent();
301-
Future<Device> emu = Devices.getInstance().getEmulator(build.isWear(), build.usesOpenGL());
301+
Future<Device> emu = Devices.getInstance().getEmulator(sdk.getToolsFolder(), build.isWear(), build.usesOpenGL());
302302
runner = new AndroidRunner(build, listener);
303303
runner.launch(emu, comp, true);
304304
}

src/processing/mode/android/Commander.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ private void execute() {
239239
if (task == RUN) {
240240
AndroidRunner runner = new AndroidRunner(build, this);
241241
runner.launch(runOnEmu ?
242-
Devices.getInstance().getEmulator(build.isWear(), build.usesOpenGL()) :
242+
Devices.getInstance().getEmulator(androidMode.getSDK().getToolsFolder(), build.isWear(), build.usesOpenGL()) :
243243
Devices.getInstance().getHardware(), build.getAppComponent(), runOnEmu);
244244
}
245245

src/processing/mode/android/Devices.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import processing.app.exec.ProcessResult;
2525
import processing.mode.android.EmulatorController.State;
2626

27+
import java.io.File;
2728
import java.io.IOException;
2829
import java.util.ArrayList;
2930
import java.util.Collections;
@@ -111,10 +112,10 @@ public void run() {
111112
}
112113

113114

114-
public Future<Device> getEmulator(final boolean wear, final boolean gpu) {
115+
public Future<Device> getEmulator(final File sdkToolsPath, final boolean wear, final boolean gpu) {
115116
final Callable<Device> androidFinder = new Callable<Device>() {
116117
public Device call() throws Exception {
117-
return blockingGetEmulator(wear, gpu);
118+
return blockingGetEmulator(sdkToolsPath, wear, gpu);
118119
}
119120
};
120121
final FutureTask<Device> task = new FutureTask<Device>(androidFinder);
@@ -123,7 +124,7 @@ public Device call() throws Exception {
123124
}
124125

125126

126-
private final Device blockingGetEmulator(final boolean wear, final boolean gpu) {
127+
private final Device blockingGetEmulator(File sdkToolsPath, final boolean wear, final boolean gpu) {
127128
// System.out.println("going looking for emulator");
128129
String port = AVD.getPort(wear);
129130
Device emu = find(true, port);
@@ -138,7 +139,7 @@ private final Device blockingGetEmulator(final boolean wear, final boolean gpu)
138139
if (emuController.getState() == State.NOT_RUNNING) {
139140
try {
140141
// System.out.println("not running, gonna launch");
141-
emuController.launch(wear, gpu); // this blocks until emulator boots
142+
emuController.launch(sdkToolsPath, wear, gpu); // this blocks until emulator boots
142143
// System.out.println("not just gonna, we've done the launch");
143144
} catch (final IOException e) {
144145
System.err.println("Problem while launching emulator.");

src/processing/mode/android/EmulatorController.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
package processing.mode.android;
2323

24+
import java.io.File;
2425
import java.io.IOException;
2526
import java.util.concurrent.CountDownLatch;
2627

@@ -60,7 +61,7 @@ public void setState(final State state) {
6061
* Blocks until emulator is running, or some catastrophe happens.
6162
* @throws IOException
6263
*/
63-
synchronized public void launch(boolean wear, boolean gpu) throws IOException {
64+
synchronized public void launch(File sdkToolsPath, boolean wear, boolean gpu) throws IOException {
6465
if (state != State.NOT_RUNNING) {
6566
String illegal = "You can't launch an emulator whose state is " + state;
6667
throw new IllegalStateException(illegal);
@@ -90,8 +91,11 @@ synchronized public void launch(boolean wear, boolean gpu) throws IOException {
9091
}
9192

9293
String gpuFlag = gpu ? "on" : "off";
94+
File emulatorPath = new File(sdkToolsPath, "emulator");
95+
if(!emulatorPath.exists())
96+
emulatorPath = new File(sdkToolsPath, "emulator.exe"); //Windows
9397
final String[] cmd = new String[] {
94-
"emulator",
98+
emulatorPath.getCanonicalPath(),
9599
"-avd", avdName,
96100
"-port", portString,
97101
// "-no-boot-anim", // does this do anything?

0 commit comments

Comments
 (0)