Skip to content

Commit e6f0565

Browse files
committed
Implement zipalign
1 parent 8709eaa commit e6f0565

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/processing/mode/android/AndroidBuild.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,8 @@ private File signPackage(File projectFolder, String keyStorePassword) throws Exc
324324
return null;
325325
}
326326

327-
// TODO zipalign package
328-
return signedPackage;
327+
File alignedPackage = zipalignPackage(signedPackage, projectFolder);
328+
return alignedPackage;
329329
} else {
330330
Base.showWarning("Error during package signing",
331331
"Verification of the signed package has failed");
@@ -358,6 +358,22 @@ private boolean verifySignedPackage(File signedPackage) throws IOException, Inte
358358
return false;
359359
}
360360

361+
private File zipalignPackage(File signedPackage, File projectFolder) throws IOException, InterruptedException {
362+
String zipalignPath = sdk.getSdkFolder().getAbsolutePath() + "/tools/zipalign";
363+
File alignedPackage = new File(projectFolder, "bin/" + sketch.getName() + "-release-signed-aligned.apk");
364+
365+
String[] args = {
366+
zipalignPath, "-v", "-f", "4",
367+
signedPackage.getAbsolutePath(), alignedPackage.getAbsolutePath()
368+
};
369+
370+
Process alignProcess = Runtime.getRuntime().exec(args);
371+
alignProcess.waitFor();
372+
373+
if(alignedPackage.exists()) return alignedPackage;
374+
return null;
375+
}
376+
361377
/*
362378
// SDK tools 17 have a problem where 'dex' won't pick up the libs folder
363379
// (which contains our friend processing-core.jar) unless your current

0 commit comments

Comments
 (0)