@@ -181,7 +181,7 @@ public boolean usesOpenGL() {
181181
182182
183183 public String getPathForAPK() {
184- String suffix = target.equals("release") ? "release_unsigned " : "debug";
184+ String suffix = target.equals("release") ? "release " : "debug";
185185 String apkName = getPathToAPK() + sketch.getName().toLowerCase() + "_" + suffix + ".apk";
186186 final File apkFile = new File(tmpFolder, apkName);
187187 if (!apkFile.exists()) {
@@ -196,9 +196,9 @@ public String getPathForAPK() {
196196 * @throws SketchException
197197 * @throws IOException
198198 */
199- public File buildBundle(String target) throws IOException, SketchException {
199+ public File buildBundle(String target, String password ) throws IOException, SketchException {
200200 this.target = target;
201- File folder = createProject(true);
201+ File folder = createProject(true, password );
202202 if (folder == null) return null;
203203 if (!gradleBuildBundle()) return null;
204204 return folder;
@@ -211,9 +211,9 @@ public File buildBundle(String target) throws IOException, SketchException {
211211 * @throws SketchException
212212 * @throws IOException
213213 */
214- public File build(String target) throws IOException, SketchException {
214+ public File build(String target, String password ) throws IOException, SketchException {
215215 this.target = target;
216- File folder = createProject(true);
216+ File folder = createProject(true, password );
217217 if (folder == null) return null;
218218 if (!gradleBuild()) return null;
219219 return folder;
@@ -225,7 +225,7 @@ public File build(String target) throws IOException, SketchException {
225225 * sketch. Creates the top and app modules in the case of regular, VR, AR and
226226 * wallpapers, and top, mobile and wear modules in the case of watch faces.
227227 */
228- protected File createProject(boolean external)
228+ protected File createProject(boolean external, String password )
229229 throws IOException, SketchException {
230230 tmpFolder = createTempBuildFolder(sketch);
231231 System.out.println(AndroidMode.getTextString("android_build.error.build_folder", tmpFolder.getAbsolutePath()));
@@ -249,7 +249,7 @@ protected File createProject(boolean external)
249249 if (sketchClassName != null) {
250250 renderer = info.getRenderer();
251251 writeMainClass(srcFolder, renderer, external);
252- createTopModule("':" + module +"'");
252+ createTopModule("':" + module +"'", password );
253253 createAppModule(module);
254254 }
255255
@@ -338,7 +338,7 @@ protected boolean gradleBuild() throws SketchException {
338338 // Gradle modules
339339
340340
341- private void createTopModule(String projectModules)
341+ private void createTopModule(String projectModules, String keyPassword )
342342 throws IOException {
343343 HashMap<String, String> replaceMap = new HashMap<String, String>();
344344
@@ -349,7 +349,13 @@ private void createTopModule(String projectModules)
349349
350350 File gradlePropsTemplate = mode.getContentFile("templates/" + GRADLE_PROPERTIES_TEMPLATE);
351351 File gradlePropsFile = new File(tmpFolder, "gradle.properties");
352- Util.copyFile(gradlePropsTemplate, gradlePropsFile);
352+ replaceMap.clear();
353+ replaceMap.put("@@keystore_file@@", AndroidKeyStore.getKeyStore().getAbsolutePath());
354+ replaceMap.put("@@key_alias@@", AndroidKeyStore.ALIAS_STRING);
355+ replaceMap.put("@@key_password@@", keyPassword);
356+
357+ AndroidUtil.createFileFromTemplate(gradlePropsTemplate, gradlePropsFile, replaceMap);
358+ // Util.copyFile(gradlePropsTemplate, gradlePropsFile);
353359
354360 File settingsTemplate = mode.getContentFile("templates/" + GRADLE_SETTINGS_TEMPLATE);
355361 File settingsFile = new File(tmpFolder, "settings.gradle");
@@ -720,7 +726,7 @@ public File exportProject() throws IOException, SketchException {
720726 target = "debug";
721727
722728 exportProject = true;
723- File projectFolder = createProject(false);
729+ File projectFolder = createProject(false, "" );
724730 exportProject = false;
725731
726732 File exportFolder = createExportFolder("android");
@@ -735,11 +741,11 @@ public File exportProject() throws IOException, SketchException {
735741
736742
737743 public File exportBundle(String keyStorePassword) throws Exception {
738- File projectFolder = buildBundle("release");
744+ File projectFolder = buildBundle("release", keyStorePassword );
739745 if (projectFolder == null) return null;
740746
741- File signedPackage = signPackage(projectFolder, keyStorePassword, "aab");
742- if (signedPackage == null) return null;
747+ // File signedPackage = signPackage(projectFolder, keyStorePassword, "aab");
748+ // if (signedPackage == null) return null;
743749
744750 // Final export folder
745751 File exportFolder = createExportFolder("buildBundle");
@@ -753,11 +759,11 @@ public File exportBundle(String keyStorePassword) throws Exception {
753759
754760
755761 public File exportPackage(String keyStorePassword) throws Exception {
756- File projectFolder = build("release");
762+ File projectFolder = build("release", keyStorePassword );
757763 if (projectFolder == null) return null;
758764
759- File signedPackage = signPackage(projectFolder, keyStorePassword, "apk");
760- if (signedPackage == null) return null;
765+ // File signedPackage = signPackage(projectFolder, keyStorePassword, "apk");
766+ // if (signedPackage == null) return null;
761767
762768 // Final export folder
763769 File exportFolder = createExportFolder("buildPackage");
@@ -766,6 +772,7 @@ public File exportPackage(String keyStorePassword) throws Exception {
766772 }
767773
768774
775+ /*
769776 private File signPackage(File projectFolder, String keyStorePassword, String fileExt) throws Exception {
770777 File keyStore = AndroidKeyStore.getKeyStore();
771778 if (keyStore == null) return null;
@@ -836,7 +843,8 @@ private File zipalignPackage(File signedPackage, File projectFolder, String file
836843
837844 if (alignedPackage.exists()) return alignedPackage;
838845 return null;
839- }
846+ }
847+ */
840848
841849
842850 //---------------------------------------------------------------------------
@@ -941,7 +949,7 @@ private void renameAAB() {
941949 String aabName = getPathToAAB() + module + "-" + suffix + ".aab";
942950 final File aabFile = new File(tmpFolder, aabName);
943951 if (aabFile.exists()) {
944- String suffixNew = target.equals("release") ? "release_unsigned " : "debug";
952+ String suffixNew = target.equals("release") ? "release " : "debug";
945953 String aabNameNew = getPathToAAB() +
946954 sketch.getName().toLowerCase() + "_" + suffixNew + ".aab";
947955 final File aabFileNew = new File(tmpFolder, aabNameNew);
@@ -955,11 +963,11 @@ private String getPathToAAB() {
955963
956964
957965 private void renameAPK() {
958- String suffix = target.equals("release") ? "release-unsigned " : "debug";
966+ String suffix = target.equals("release") ? "release" : "debug";
959967 String apkName = getPathToAPK() + module + "-" + suffix + ".apk";
960968 final File apkFile = new File(tmpFolder, apkName);
961969 if (apkFile.exists()) {
962- String suffixNew = target.equals("release") ? "release_unsigned " : "debug";
970+ String suffixNew = target.equals("release") ? "release " : "debug";
963971 String apkNameNew = getPathToAPK() +
964972 sketch.getName().toLowerCase() + "_" + suffixNew + ".apk";
965973 final File apkFileNew = new File(tmpFolder, apkNameNew);
0 commit comments