@@ -181,7 +181,7 @@ public boolean usesOpenGL() {
181
181
182
182
183
183
public String getPathForAPK () {
184
- String suffix = target .equals ("release" ) ? "release_unsigned " : "debug" ;
184
+ String suffix = target .equals ("release" ) ? "release " : "debug" ;
185
185
String apkName = getPathToAPK () + sketch .getName ().toLowerCase () + "_" + suffix + ".apk" ;
186
186
final File apkFile = new File (tmpFolder , apkName );
187
187
if (!apkFile .exists ()) {
@@ -196,9 +196,9 @@ public String getPathForAPK() {
196
196
* @throws SketchException
197
197
* @throws IOException
198
198
*/
199
- public File buildBundle (String target ) throws IOException , SketchException {
199
+ public File buildBundle (String target , String password ) throws IOException , SketchException {
200
200
this .target = target ;
201
- File folder = createProject (true );
201
+ File folder = createProject (true , password );
202
202
if (folder == null ) return null ;
203
203
if (!gradleBuildBundle ()) return null ;
204
204
return folder ;
@@ -211,9 +211,9 @@ public File buildBundle(String target) throws IOException, SketchException {
211
211
* @throws SketchException
212
212
* @throws IOException
213
213
*/
214
- public File build (String target ) throws IOException , SketchException {
214
+ public File build (String target , String password ) throws IOException , SketchException {
215
215
this .target = target ;
216
- File folder = createProject (true );
216
+ File folder = createProject (true , password );
217
217
if (folder == null ) return null ;
218
218
if (!gradleBuild ()) return null ;
219
219
return folder ;
@@ -225,7 +225,7 @@ public File build(String target) throws IOException, SketchException {
225
225
* sketch. Creates the top and app modules in the case of regular, VR, AR and
226
226
* wallpapers, and top, mobile and wear modules in the case of watch faces.
227
227
*/
228
- protected File createProject (boolean external )
228
+ protected File createProject (boolean external , String password )
229
229
throws IOException , SketchException {
230
230
tmpFolder = createTempBuildFolder (sketch );
231
231
System .out .println (AndroidMode .getTextString ("android_build.error.build_folder" , tmpFolder .getAbsolutePath ()));
@@ -249,7 +249,7 @@ protected File createProject(boolean external)
249
249
if (sketchClassName != null ) {
250
250
renderer = info .getRenderer ();
251
251
writeMainClass (srcFolder , renderer , external );
252
- createTopModule ("':" + module +"'" );
252
+ createTopModule ("':" + module +"'" , password );
253
253
createAppModule (module );
254
254
}
255
255
@@ -338,7 +338,7 @@ protected boolean gradleBuild() throws SketchException {
338
338
// Gradle modules
339
339
340
340
341
- private void createTopModule (String projectModules )
341
+ private void createTopModule (String projectModules , String keyPassword )
342
342
throws IOException {
343
343
HashMap <String , String > replaceMap = new HashMap <String , String >();
344
344
@@ -349,7 +349,13 @@ private void createTopModule(String projectModules)
349
349
350
350
File gradlePropsTemplate = mode .getContentFile ("templates/" + GRADLE_PROPERTIES_TEMPLATE );
351
351
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);
353
359
354
360
File settingsTemplate = mode .getContentFile ("templates/" + GRADLE_SETTINGS_TEMPLATE );
355
361
File settingsFile = new File (tmpFolder , "settings.gradle" );
@@ -720,7 +726,7 @@ public File exportProject() throws IOException, SketchException {
720
726
target = "debug" ;
721
727
722
728
exportProject = true ;
723
- File projectFolder = createProject (false );
729
+ File projectFolder = createProject (false , "" );
724
730
exportProject = false ;
725
731
726
732
File exportFolder = createExportFolder ("android" );
@@ -735,11 +741,11 @@ public File exportProject() throws IOException, SketchException {
735
741
736
742
737
743
public File exportBundle (String keyStorePassword ) throws Exception {
738
- File projectFolder = buildBundle ("release" );
744
+ File projectFolder = buildBundle ("release" , keyStorePassword );
739
745
if (projectFolder == null ) return null ;
740
746
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;
743
749
744
750
// Final export folder
745
751
File exportFolder = createExportFolder ("buildBundle" );
@@ -753,11 +759,11 @@ public File exportBundle(String keyStorePassword) throws Exception {
753
759
754
760
755
761
public File exportPackage (String keyStorePassword ) throws Exception {
756
- File projectFolder = build ("release" );
762
+ File projectFolder = build ("release" , keyStorePassword );
757
763
if (projectFolder == null ) return null ;
758
764
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;
761
767
762
768
// Final export folder
763
769
File exportFolder = createExportFolder ("buildPackage" );
@@ -766,6 +772,7 @@ public File exportPackage(String keyStorePassword) throws Exception {
766
772
}
767
773
768
774
775
+ /*
769
776
private File signPackage(File projectFolder, String keyStorePassword, String fileExt) throws Exception {
770
777
File keyStore = AndroidKeyStore.getKeyStore();
771
778
if (keyStore == null) return null;
@@ -836,7 +843,8 @@ private File zipalignPackage(File signedPackage, File projectFolder, String file
836
843
837
844
if (alignedPackage.exists()) return alignedPackage;
838
845
return null;
839
- }
846
+ }
847
+ */
840
848
841
849
842
850
//---------------------------------------------------------------------------
@@ -941,7 +949,7 @@ private void renameAAB() {
941
949
String aabName = getPathToAAB () + module + "-" + suffix + ".aab" ;
942
950
final File aabFile = new File (tmpFolder , aabName );
943
951
if (aabFile .exists ()) {
944
- String suffixNew = target .equals ("release" ) ? "release_unsigned " : "debug" ;
952
+ String suffixNew = target .equals ("release" ) ? "release " : "debug" ;
945
953
String aabNameNew = getPathToAAB () +
946
954
sketch .getName ().toLowerCase () + "_" + suffixNew + ".aab" ;
947
955
final File aabFileNew = new File (tmpFolder , aabNameNew );
@@ -955,11 +963,11 @@ private String getPathToAAB() {
955
963
956
964
957
965
private void renameAPK () {
958
- String suffix = target .equals ("release" ) ? "release-unsigned " : "debug" ;
966
+ String suffix = target .equals ("release" ) ? "release" : "debug" ;
959
967
String apkName = getPathToAPK () + module + "-" + suffix + ".apk" ;
960
968
final File apkFile = new File (tmpFolder , apkName );
961
969
if (apkFile .exists ()) {
962
- String suffixNew = target .equals ("release" ) ? "release_unsigned " : "debug" ;
970
+ String suffixNew = target .equals ("release" ) ? "release " : "debug" ;
963
971
String apkNameNew = getPathToAPK () +
964
972
sketch .getName ().toLowerCase () + "_" + suffixNew + ".apk" ;
965
973
final File apkFileNew = new File (tmpFolder , apkNameNew );
0 commit comments