@@ -63,7 +63,6 @@ class AndroidBuild extends JavaBuild {
63
63
static {
64
64
TARGET_SDK = Preferences .get ("android.sdk.target" );
65
65
if (TARGET_SDK == null || PApplet .parseInt (TARGET_SDK ) < 26 ) {
66
- // Must be 8.0 or higher
67
66
TARGET_SDK = "26" ;
68
67
Preferences .set ("android.sdk.target" , TARGET_SDK );
69
68
}
@@ -76,7 +75,7 @@ class AndroidBuild extends JavaBuild {
76
75
static public String SUPPORT_VER ;
77
76
static {
78
77
SUPPORT_VER = Preferences .get ("android.sdk.support" );
79
- if (SUPPORT_VER == null ) {
78
+ if (SUPPORT_VER == null || ! versionCheck ( SUPPORT_VER , "26.0.2" )) {
80
79
SUPPORT_VER = "26.0.2" ;
81
80
Preferences .set ("android.sdk.support" , SUPPORT_VER );
82
81
}
@@ -85,7 +84,7 @@ class AndroidBuild extends JavaBuild {
85
84
static public String PLAY_SERVICES_VER ;
86
85
static {
87
86
PLAY_SERVICES_VER = Preferences .get ("android.sdk.play_services" );
88
- if (PLAY_SERVICES_VER == null ) {
87
+ if (PLAY_SERVICES_VER == null || ! versionCheck ( PLAY_SERVICES_VER , "11.0.4" )) {
89
88
PLAY_SERVICES_VER = "11.0.4" ;
90
89
Preferences .set ("android.sdk.play_services" , PLAY_SERVICES_VER );
91
90
}
@@ -94,7 +93,7 @@ class AndroidBuild extends JavaBuild {
94
93
static public String WEAR_VER ;
95
94
static {
96
95
WEAR_VER = Preferences .get ("android.sdk.wear" );
97
- if (WEAR_VER == null ) {
96
+ if (WEAR_VER == null || ! versionCheck ( WEAR_VER , "2.1.0" )) {
98
97
WEAR_VER = "2.1.0" ;
99
98
Preferences .set ("android.sdk.wear" , WEAR_VER );
100
99
}
@@ -103,7 +102,7 @@ class AndroidBuild extends JavaBuild {
103
102
static public String GVR_VER ;
104
103
static {
105
104
GVR_VER = Preferences .get ("android.sdk.gvr" );
106
- if (GVR_VER == null ) {
105
+ if (GVR_VER == null || ! versionCheck ( GVR_VER , "1.150.0" )) {
107
106
GVR_VER = "1.150.0" ;
108
107
Preferences .set ("android.sdk.gvr" , GVR_VER );
109
108
}
@@ -980,4 +979,43 @@ private void installGradlew(File exportFolder) throws IOException {
980
979
private File createExportFolder (String name ) throws IOException {
981
980
return AndroidUtil .createSubFolder (sketch .getFolder (), name );
982
981
}
982
+
983
+
984
+ static private boolean versionCheck (String currentVersion , String minVersion ) {
985
+ String [] currentPieces = currentVersion .split ("\\ ." );
986
+ String [] minPieces = minVersion .split ("\\ ." );
987
+
988
+ if (currentPieces .length == 3 && minPieces .length == 3 ) {
989
+ int currentMajor = PApplet .parseInt (currentPieces [0 ], -1 );
990
+ int currentMinor = PApplet .parseInt (currentPieces [1 ], -1 );
991
+ int currentMicro = PApplet .parseInt (currentPieces [2 ], -1 );
992
+
993
+ int minMajor = PApplet .parseInt (minPieces [0 ], -1 );
994
+ int minMinor = PApplet .parseInt (minPieces [1 ], -1 );
995
+ int minMicro = PApplet .parseInt (minPieces [2 ], -1 );
996
+
997
+ if (-1 < currentMajor && -1 < currentMinor && -1 < currentMicro &&
998
+ -1 < minMajor && -1 < minMinor && -1 < minMicro ) {
999
+ if (currentMajor < minMajor ) {
1000
+ return false ;
1001
+ } else if (currentMajor == minMajor ) {
1002
+ if (currentMinor < minMinor ) {
1003
+ return false ;
1004
+ } if (currentMinor == minMinor ) {
1005
+ if (currentMicro < minMicro ) {
1006
+ return false ;
1007
+ } else {
1008
+ return true ;
1009
+ }
1010
+ } else {
1011
+ return true ;
1012
+ }
1013
+ } else {
1014
+ return true ;
1015
+ }
1016
+ }
1017
+ }
1018
+
1019
+ return false ;
1020
+ }
983
1021
}
0 commit comments