@@ -63,6 +63,7 @@ class AndroidBuild extends JavaBuild {
6363 // Versions of all required dependencies
6464 static public String TARGET_SDK ;
6565 static public String TARGET_PLATFORM ;
66+ static public String GRADLE_VER ;
6667 static public String APPCOMPAT_VER ;
6768 static public String V4LEGACY_VER ;
6869 static public String PLAY_SERVICES_VER ;
@@ -287,18 +288,21 @@ protected boolean gradleBuild() throws SketchException {
287288
288289
289290 private void createTopModule (String projectModules )
290- throws IOException {
291+ throws IOException {
292+ HashMap <String , String > replaceMap = new HashMap <String , String >();
293+
291294 File buildTemplate = mode .getContentFile ("templates/" + TOP_GRADLE_BUILD_TEMPLATE );
292295 File buildlFile = new File (tmpFolder , "build.gradle" );
293- Util .copyFile (buildTemplate , buildlFile );
296+ replaceMap .put ("@@gradle_version@@" , GRADLE_VER );
297+ AndroidUtil .createFileFromTemplate (buildTemplate , buildlFile , replaceMap );
294298
295299 File gradlePropsTemplate = mode .getContentFile ("templates/" + GRADLE_PROPERTIES_TEMPLATE );
296300 File gradlePropsFile = new File (tmpFolder , "gradle.properties" );
297301 Util .copyFile (gradlePropsTemplate , gradlePropsFile );
298302
299303 File settingsTemplate = mode .getContentFile ("templates/" + GRADLE_SETTINGS_TEMPLATE );
300304 File settingsFile = new File (tmpFolder , "settings.gradle" );
301- HashMap < String , String > replaceMap = new HashMap < String , String > ();
305+ replaceMap . clear ();
302306 replaceMap .put ("@@project_modules@@" , projectModules );
303307 AndroidUtil .createFileFromTemplate (settingsTemplate , settingsFile , replaceMap );
304308
@@ -903,9 +907,15 @@ static public void initVersions(File file) {
903907 MIN_SDK_AR = props .getProperty ("android-min-ar" );
904908 MIN_SDK_WATCHFACE = props .getProperty ("android-min-wear" );
905909
906- // Versions of the target sdk, support, play services, wear, VR, and AR are stored in
907- // preferences file so they can be changed by the user without having to rebuilt/reinstall
908- // the mode.
910+ // Versions strings of all dependencies are stored in a preferences file so they can be changed by the
911+ // user without having to rebuild/reinstall the mode.
912+
913+ GRADLE_VER = Preferences .get ("android.gradle" );
914+ String defGradleVersion = props .getProperty ("gradle" );
915+ if (GRADLE_VER == null || PApplet .parseInt (GRADLE_VER ) != PApplet .parseInt (defGradleVersion )) {
916+ GRADLE_VER = defGradleVersion ;
917+ Preferences .set ("android.gradle" , GRADLE_VER );
918+ }
909919
910920 TARGET_SDK = Preferences .get ("android.sdk.target" );
911921 String defTargetSDK = props .getProperty ("android-platform" );
0 commit comments