mirror of
https://github.com/processing/processing4.git
synced 2026-02-14 10:55:38 +01:00
fixes for new Android tools, plus more error handling and bug fixes
This commit is contained in:
@@ -103,6 +103,9 @@ public class AVD {
|
||||
list(sdk);
|
||||
}
|
||||
for (String avd : avdList) {
|
||||
if (Base.DEBUG) {
|
||||
System.out.println("AVD.exists() checking for " + name + " against " + avd);
|
||||
}
|
||||
if (avd.equals(name)) {
|
||||
return true;
|
||||
}
|
||||
@@ -131,6 +134,9 @@ public class AVD {
|
||||
"-s", DEFAULT_SKIN
|
||||
};
|
||||
|
||||
// Set the list to null so that exists() will check again
|
||||
avdList = null;
|
||||
|
||||
final ProcessHelper p = new ProcessHelper(params);
|
||||
try {
|
||||
final ProcessResult createAvdResult = p.execute();
|
||||
@@ -150,7 +156,7 @@ public class AVD {
|
||||
}
|
||||
//System.err.println(createAvdResult);
|
||||
} catch (final InterruptedException ie) { }
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ import processing.mode.java.JavaBuild;
|
||||
|
||||
|
||||
class AndroidBuild extends JavaBuild {
|
||||
static final String basePackage = "processing.changethispackage.beforesubmittingtothemarket";
|
||||
static final String basePackage = "changethispackage.beforesubmitting.tothemarket";
|
||||
static final String sdkVersion = "8";
|
||||
static final String sdkTarget = "android-" + sdkVersion;
|
||||
|
||||
|
||||
@@ -55,7 +55,10 @@ public class AndroidRunner implements DeviceListener {
|
||||
// final Device device = waitForDevice(deviceFuture, monitor);
|
||||
final Device device = waitForDevice(deviceFuture, listener);
|
||||
if (device == null || !device.isAlive()) {
|
||||
listener.statusError("Device killed or disconnected.");
|
||||
listener.statusError("Lost connection with device while launching. Try again.");
|
||||
// Reset the server, in case that's the problem. Sometimes when
|
||||
// launching the emulator times out, the device list refuses to update.
|
||||
Devices.killAdbServer();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -69,7 +72,8 @@ public class AndroidRunner implements DeviceListener {
|
||||
// monitor.setNote("Installing sketch on " + device.getId());
|
||||
listener.statusNotice("Installing sketch on " + device.getId());
|
||||
if (!device.installApp(build.getPathForAPK(), listener)) {
|
||||
listener.statusError("Device killed or disconnected.");
|
||||
listener.statusError("Lost connection with device while installing. Try again.");
|
||||
Devices.killAdbServer(); // see above
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import processing.app.Base;
|
||||
import processing.app.RunnerListener;
|
||||
import processing.app.exec.LineProcessor;
|
||||
import processing.app.exec.ProcessRegistry;
|
||||
@@ -93,9 +94,21 @@ class Device implements DeviceProperties {
|
||||
if (!isAlive()) {
|
||||
return false;
|
||||
}
|
||||
return adb("shell", "am", "start", "-e", "debug", "true", "-a",
|
||||
"android.intent.action.MAIN", "-c", "android.intent.category.LAUNCHER",
|
||||
"-n", packageName + "/." + className).succeeded();
|
||||
ProcessResult pr = adb("shell", "am", "start", "-e", "debug", "true",
|
||||
"-a", "android.intent.action.MAIN",
|
||||
"-c", "android.intent.category.LAUNCHER",
|
||||
"-n", packageName + "/." + className);
|
||||
if (Base.DEBUG) {
|
||||
System.out.println(pr.toString());
|
||||
}
|
||||
// Sometimes this shows up on stdout, even though it returns 'success'
|
||||
// Error type 2
|
||||
// android.util.AndroidException: Can't connect to activity manager; is the system running?
|
||||
if (pr.getStdout().contains("android.util.AndroidException")) {
|
||||
System.err.println(pr.getStdout());
|
||||
return false;
|
||||
}
|
||||
return pr.succeeded();
|
||||
}
|
||||
|
||||
public boolean isEmulator() {
|
||||
@@ -256,8 +269,7 @@ class Device implements DeviceProperties {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
private ProcessResult adb(final String... cmd) throws InterruptedException,
|
||||
IOException {
|
||||
private ProcessResult adb(final String... cmd) throws InterruptedException, IOException {
|
||||
final String[] adbCmd = generateAdbCommand(cmd);
|
||||
return AndroidSDK.runADB(adbCmd);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user