Skip to content

Commit 0e4d7d2

Browse files
committed
added getZipAlignTool() method to AndroidSDK
1 parent a2c4218 commit 0e4d7d2

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

src/processing/mode/android/AVD.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,9 @@ protected void getImages(final ArrayList<String> images, final AndroidSDK sdk,
329329
// TODO : Find a better way to get the list of installed images
330330
ProcessBuilder pb = new ProcessBuilder(cmd);
331331

332-
//if (Base.DEBUG) {
333-
System.out.println(processing.core.PApplet.join(cmd, " "));
334-
//}
332+
if (Base.DEBUG) {
333+
System.out.println(processing.core.PApplet.join(cmd, " "));
334+
}
335335

336336
Map<String, String> env = pb.environment();
337337
env.clear();
@@ -345,12 +345,12 @@ protected void getImages(final ArrayList<String> images, final AndroidSDK sdk,
345345
output.addTarget(new LineProcessor() {
346346
@Override
347347
public void processLine(String line) {
348-
System.out.println("DUMMY ---> " + line);
348+
System.out.println("dummy output ---> " + line);
349349
if (images != null &&
350350
line.contains(";" + imagePlatform) &&
351351
line.contains(";" + imageTag) &&
352352
line.contains(";" + imageAbi)) {
353-
System.out.println(" added!");
353+
System.out.println(" added image!");
354354
images.add(line);
355355
}
356356
}
@@ -402,9 +402,9 @@ protected boolean create(final AndroidSDK sdk) throws IOException {
402402

403403
ProcessBuilder pb = new ProcessBuilder(cmd);
404404

405-
//if (Base.DEBUG) {
405+
if (Base.DEBUG) {
406406
System.out.println(processing.core.PApplet.join(cmd, " "));
407-
//}
407+
}
408408

409409
// avdmanager create avd -n "Wear-Processing-0254" -k "system-images;android-25;google_apis;x86" -c 64M
410410

src/processing/mode/android/AndroidBuild.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -786,11 +786,8 @@ private File signPackage(File projectFolder, String keyStorePassword) throws Exc
786786

787787
private File zipalignPackage(File signedPackage, File projectFolder)
788788
throws IOException, InterruptedException {
789-
790-
File buildToolsFolder = new File(sdk.getSdkFolder(), "build-tools").listFiles()[0];
791-
String zipalignPath = buildToolsFolder.getAbsolutePath() + "/zipalign";
792-
if (Platform.isWindows()) zipalignPath += ".exe";
793-
if (!new File(zipalignPath).exists()) {
789+
File zipAlign = sdk.getZipAlignTool();
790+
if (zipAlign == null || !zipAlign.exists()) {
794791
Messages.showWarning("Cannot find zipaling...",
795792
"The zipalign build tool needed to prepare the export package is missing.\n" +
796793
"Make sure that your Android SDK was downloaded correctly.");
@@ -801,7 +798,7 @@ private File zipalignPackage(File signedPackage, File projectFolder)
801798
module + "/build/outputs/apk/" + sketch.getName().toLowerCase() + "_release_signed_aligned.apk");
802799

803800
String[] args = {
804-
zipalignPath, "-v", "-f", "4",
801+
zipAlign.getAbsolutePath(), "-v", "-f", "4",
805802
signedPackage.getAbsolutePath(), alignedPackage.getAbsolutePath()
806803
};
807804

src/processing/mode/android/AndroidSDK.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,16 @@ public File getSupportLibrary() {
322322
}
323323

324324

325+
public File getZipAlignTool() {
326+
File[] files = buildTools.listFiles();
327+
String name = Platform.isWindows() ? "zipalign.exe" : "zipalign";
328+
for (File f: files) {
329+
File z = new File(f, name);
330+
if (z.exists()) return z;
331+
}
332+
return null;
333+
}
334+
325335
static public File getHAXMInstallerFolder() {
326336
String sdkPrefsPath = Preferences.get("android.sdk.path");
327337
File sdkPath = new File(sdkPrefsPath);
@@ -385,13 +395,10 @@ public static AndroidSDK load(boolean checkEnvSDK, Frame editor) throws IOExcept
385395
}
386396

387397
final String sdkEnvPath = Platform.getenv("ANDROID_SDK");
388-
System.out.println("ANDROID_SDK: " + sdkEnvPath);
389398
if (sdkEnvPath != null) {
390399
try {
391400
final AndroidSDK androidSDK = new AndroidSDK(new File(sdkEnvPath));
392401

393-
System.out.println("ENVIRONMENT SDK CAN BE USED BY PROCESSING!!");
394-
395402
if (checkEnvSDK && editor != null) {
396403
// There is a valid SDK in the environment, but let's give the user
397404
// the option to not to use it. After this, we should go straight to

0 commit comments

Comments
 (0)