Skip to content

Commit 46d9b20

Browse files
committed
Merge pull request #66 from imilka/bugfixes
Bugfixes
2 parents 21def7c + 5f48a79 commit 46d9b20

File tree

5 files changed

+29
-8
lines changed

5 files changed

+29
-8
lines changed

src/processing/mode/android/AVD.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package processing.mode.android;
22

3-
import java.io.IOException;
4-
import java.util.ArrayList;
5-
63
import processing.app.Base;
74
import processing.app.exec.ProcessHelper;
85
import processing.app.exec.ProcessResult;
96
import processing.core.PApplet;
107

8+
import java.io.IOException;
9+
import java.util.ArrayList;
10+
1111

1212
public class AVD {
1313
static private final String AVD_CREATE_PRIMARY =
@@ -137,7 +137,8 @@ protected boolean create(final AndroidSDK sdk) throws IOException {
137137
"-n", name,
138138
"-t", target,
139139
"-c", DEFAULT_SDCARD_SIZE,
140-
"-s", DEFAULT_SKIN
140+
"-s", DEFAULT_SKIN,
141+
"--abi", "armeabi"
141142
};
142143

143144
// Set the list to null so that exists() will check again

src/processing/mode/android/AndroidBuild.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,10 @@ private File signPackage(File projectFolder, String keyStorePassword) throws Exc
350350
} */
351351

352352
private File zipalignPackage(File signedPackage, File projectFolder) throws IOException, InterruptedException {
353-
String zipalignPath = sdk.getSdkFolder().getAbsolutePath() + "/tools/zipalign";
353+
354+
File buildToolsFolder = new File(sdk.getSdkFolder(), "build-tools").listFiles()[0];
355+
String zipalignPath = buildToolsFolder.getAbsolutePath() + "/zipalign";
356+
354357
File alignedPackage = new File(projectFolder, "bin/" + sketch.getName() + "-release-signed-aligned.apk");
355358

356359
String[] args = {

src/processing/mode/android/AndroidRunner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void launch(Future<Device> deviceFuture) {
7272
// monitor.setNote("Installing sketch on " + device.getId());
7373
listener.statusNotice("Installing sketch on " + device.getId());
7474
// this stopped working with Android SDK tools revision 17
75-
if (!device.installApp(build.getPathForAPK(), listener)) {
75+
if (!device.installApp(build, listener)) {
7676
listener.statusError("Lost connection with device while installing. Try again.");
7777
Devices.killAdbServer(); // see above
7878
return;

src/processing/mode/android/Device.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ public String getName() {
7878
// Success
7979

8080
// safe to just always include the -r (reinstall) flag
81-
public boolean installApp(final String apkPath, final RunnerListener status) {
81+
public boolean installApp(final AndroidBuild build, final RunnerListener status) {
8282
if (!isAlive()) {
8383
return false;
8484
}
8585
bringLauncherToFront();
8686
try {
87-
final ProcessResult installResult = adb("install", "-r", apkPath);
87+
final ProcessResult installResult = adb("install", "-r", build.getPathForAPK());
8888
if (!installResult.succeeded()) {
8989
status.statusError("Could not install the sketch.");
9090
System.err.println(installResult);
@@ -94,6 +94,12 @@ public boolean installApp(final String apkPath, final RunnerListener status) {
9494
for (final String line : installResult) {
9595
if (line.startsWith("Failure")) {
9696
errorMsg = line.substring(8);
97+
98+
if(line.contains("INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES")) {
99+
boolean removeResult = removeApp(build.getPackageName());
100+
if(removeResult) return installApp(build, status);
101+
}
102+
97103
System.err.println(line);
98104
}
99105
}
@@ -109,6 +115,16 @@ public boolean installApp(final String apkPath, final RunnerListener status) {
109115
return false;
110116
}
111117

118+
public boolean removeApp(String packageName) throws IOException, InterruptedException {
119+
final ProcessResult removeResult = adb("uninstall", packageName);
120+
121+
if (!removeResult.succeeded()) {
122+
return false;
123+
}
124+
125+
return true;
126+
}
127+
112128

113129
// different version that actually runs through JDI:
114130
// http://asantoso.wordpress.com/2009/09/26/using-jdb-with-adb-to-debugging-of-android-app-on-a-real-device/

src/processing/mode/android/SDKDownloader.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ protected Object doInBackground() throws Exception {
9898
tempFolder.delete();
9999

100100
Base.getPlatform().setenv("ANDROID_SDK", sdkFolder.getAbsolutePath());
101+
Preferences.set("android.sdk.path", sdkFolder.getAbsolutePath());
101102
androidMode.loadSDK();
102103
} catch (ParserConfigurationException e) {
103104
// TODO Handle exceptions here somehow (ie show error message) and handle at least mkdir() results (above)

0 commit comments

Comments
 (0)