1
+ apply plugin : ' android'
2
+
1
3
android {
2
- buildToolsVersion " 23.0.3"
3
- compileSdkVersion 23
4
- sourceSets {
4
+ buildToolsVersion latestBuildToolsAvailable(" 26.0.2" )
5
+ compileSdkVersion highestSdkAvailable(26 )
6
+
7
+ defaultConfig {
8
+ applicationId " com.bladecoder.advtest"
9
+ minSdkVersion 15
10
+ targetSdkVersion 26
11
+ versionName version
12
+
13
+ if (project. hasProperty(' versionCode' ))
14
+ versionCode project. versionCode. toInteger()
15
+ else
16
+ versionCode 1
17
+
18
+ buildConfigField " int" , " EXPANSION_FILE_VERSION" , " 0"
19
+ }
20
+
21
+ productFlavors {
22
+ full {
23
+ }
24
+
25
+ expansion {
26
+ buildConfigField " int" , " EXPANSION_FILE_VERSION" , String . valueOf(android. defaultConfig. versionCode)
27
+ }
28
+ }
29
+
30
+ sourceSets {
5
31
main {
6
32
manifest. srcFile ' AndroidManifest.xml'
7
- java. srcDirs = [' src' ]
8
- aidl. srcDirs = [' src' ]
9
- renderscript. srcDirs = [' src' ]
33
+ java. srcDirs = [' src/main/java ' ]
34
+ aidl. srcDirs = [' src/main/java ' ]
35
+ renderscript. srcDirs = [' src/main/java ' ]
10
36
res. srcDirs = [' res' ]
11
- assets. srcDirs = [' assets' ]
12
37
jniLibs. srcDirs = [' libs' ]
13
38
}
14
39
40
+ full. assets. srcDirs = [' ../assets' ]
41
+ expansion. assets. srcDirs = [' ../base-assets' ]
42
+
15
43
instrumentTest. setRoot(' tests' )
16
-
17
-
18
44
}
19
45
20
-
21
- defaultConfig {
22
- applicationId " com.bladecoder.advtest"
23
- minSdkVersion 15
24
- targetSdkVersion 23
25
- }
46
+ packagingOptions {
47
+ // Preventing from license violations (more or less):
48
+ pickFirst ' META-INF/LICENSE.txt'
49
+ pickFirst ' META-INF/LICENSE'
50
+ pickFirst ' META-INF/license.txt'
51
+ pickFirst ' META-INF/LGPL2.1'
52
+ pickFirst ' META-INF/NOTICE.txt'
53
+ pickFirst ' META-INF/NOTICE'
54
+ pickFirst ' META-INF/notice.txt'
55
+ // Excluding unnecessary meta-data:
56
+ exclude ' META-INF/robovm/ios/robovm.xml'
57
+ exclude ' META-INF/DEPENDENCIES.txt'
58
+ exclude ' META-INF/DEPENDENCIES'
59
+ exclude ' META-INF/dependencies.txt'
60
+ }
26
61
27
- if (project. hasProperty(' keystore' )) {
62
+ if (project. hasProperty(' keystore' )) {
28
63
signingConfigs {
29
64
release {
30
- storeFile file(project. keystore)
31
- storePassword project. storePassword
32
- keyAlias project. alias
33
- keyPassword project. keyPassword
65
+ storeFile file(project. keystore)
66
+ storePassword project. storePassword
67
+ keyAlias project. alias
68
+ keyPassword project. keyPassword
34
69
}
35
70
}
36
-
37
- buildTypes {
38
- release {
39
- signingConfig signingConfigs. release
40
- }
71
+
72
+ buildTypes {
73
+ release {
74
+ signingConfig signingConfigs. release
75
+ }
41
76
}
42
- }
77
+ }
78
+
79
+ buildTypes {
80
+ release {
81
+ minifyEnabled false
82
+ proguardFiles getDefaultProguardFile(' proguard-android.txt' ), ' proguard-rules.pro'
83
+ }
84
+ }
85
+ }
86
+
87
+ configurations { natives }
88
+
89
+ dependencies {
90
+ compile project(" :core" )
91
+ compile " com.badlogicgames.gdx:gdx-backend-android:$gdxVersion "
92
+ natives " com.badlogicgames.gdx:gdx-platform:$gdxVersion :natives-armeabi"
93
+ natives " com.badlogicgames.gdx:gdx-platform:$gdxVersion :natives-armeabi-v7a"
94
+ natives " com.badlogicgames.gdx:gdx-platform:$gdxVersion :natives-arm64-v8a"
95
+ natives " com.badlogicgames.gdx:gdx-platform:$gdxVersion :natives-x86"
96
+ natives " com.badlogicgames.gdx:gdx-platform:$gdxVersion :natives-x86_64"
97
+ natives " com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion :natives-armeabi"
98
+ natives " com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion :natives-armeabi-v7a"
99
+ natives " com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion :natives-arm64-v8a"
100
+ natives " com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion :natives-x86"
101
+ natives " com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion :natives-x86_64"
43
102
}
44
103
45
104
// called every time gradle gets executed, takes the native dependencies of
46
105
// the natives configuration, and extracts them to the proper libs/ folders
47
106
// so they get packed with the APK.
48
- task copyAndroidNatives () {
107
+ task copyAndroidNatives () {
49
108
file(" libs/armeabi/" ). mkdirs();
50
109
file(" libs/armeabi-v7a/" ). mkdirs();
110
+ file(" libs/arm64-v8a/" ). mkdirs();
111
+ file(" libs/x86_64/" ). mkdirs();
51
112
file(" libs/x86/" ). mkdirs();
52
113
53
114
configurations. natives. files. each { jar ->
54
115
def outputDir = null
116
+ if (jar. name. endsWith(" natives-arm64-v8a.jar" )) outputDir = file(" libs/arm64-v8a" )
55
117
if (jar. name. endsWith(" natives-armeabi-v7a.jar" )) outputDir = file(" libs/armeabi-v7a" )
56
118
if (jar. name. endsWith(" natives-armeabi.jar" )) outputDir = file(" libs/armeabi" )
119
+ if (jar. name. endsWith(" natives-x86_64.jar" )) outputDir = file(" libs/x86_64" )
57
120
if (jar. name. endsWith(" natives-x86.jar" )) outputDir = file(" libs/x86" )
58
121
if (outputDir != null ) {
59
122
copy {
@@ -84,7 +147,28 @@ task run(type: Exec) {
84
147
}
85
148
86
149
def adb = path + " /platform-tools/adb"
87
- commandLine " $adb " , ' shell' , ' am' , ' start' , ' -n' , ' com.bladecoder.advtest/com.bladecoder.engine.android.AndroidLauncher'
150
+ commandLine " $adb " , ' shell' , ' am' , ' start' , ' -n' , android. defaultConfig. applicationId + ' /' + android. defaultConfig. applicationId + ' .AndroidLauncher'
151
+ }
152
+
153
+ task(' packageMainExpansionFile' , type : Zip ) {
154
+
155
+ FileTree tree = fileTree(dir : ' ../assets' )
156
+
157
+ from tree
158
+ // into 'assets'
159
+
160
+ // Expansion file name format: main.versionCode.packageName.obb
161
+ entryCompression = ZipEntryCompression . STORED
162
+ archiveName = ' main.' + android. defaultConfig. versionCode + " ." + android. defaultConfig. applicationId + " .obb"
163
+
164
+ println " Generating main." + archiveName
165
+
166
+ }
167
+
168
+ tasks. whenTaskAdded { task ->
169
+ if (task. name == ' generateExpansionReleaseBuildConfig' ) {
170
+ task. dependsOn packageMainExpansionFile
171
+ }
88
172
}
89
173
90
174
// sets up the Android Eclipse project, using the old Ant based build.
@@ -93,18 +177,18 @@ eclipse {
93
177
// ignores any nodes added in classpath.file.withXml
94
178
sourceSets {
95
179
main {
96
- java. srcDirs " src" , ' gen'
180
+ java. srcDirs " src/main/java " , ' gen'
97
181
}
98
182
}
99
183
100
184
jdt {
101
- sourceCompatibility = 1.6
102
- targetCompatibility = 1.6
185
+ sourceCompatibility= 1.7
186
+ targetCompatibility= 1.7
103
187
}
104
188
105
189
classpath {
106
- plusConfigurations + = [ project. configurations. compile ]
107
- containers ' com.android.ide.eclipse.adt.ANDROID_FRAMEWORK' , ' com.android.ide.eclipse.adt.LIBRARIES'
190
+ plusConfigurations + = [ project. configurations. compile ]
191
+ containers ' com.android.ide.eclipse.adt.ANDROID_FRAMEWORK' , ' com.android.ide.eclipse.adt.LIBRARIES'
108
192
}
109
193
110
194
project {
@@ -122,7 +206,7 @@ eclipse {
122
206
idea {
123
207
module {
124
208
sourceDirs + = file(" src" );
125
- scopes = [ COMPILE : [plus :[project. configurations. compile]]]
209
+ scopes = [ COMPILE : [plus :[project. configurations. compile]]]
126
210
127
211
iml {
128
212
withXml {
@@ -139,4 +223,44 @@ idea {
139
223
}
140
224
}
141
225
}
226
+ }
227
+
228
+
229
+ int highestSdkAvailable (int defaultSdk ) {
230
+ try {
231
+ def buildToolsDir = new File (android. getSdkDirectory(). toString(), " platforms" )
232
+ def sdks = buildToolsDir. list([accept :{ d , f -> f. startsWith(" android-" ) && new File (d, f). isDirectory() }] as FilenameFilter ). sort { a , b -> b <=> a }
233
+ def highestSdk = sdks[0 ]
234
+ if (highestSdk != null ) {
235
+ println " Using highest found SDK " + highestSdk. substring(8 )
236
+ highestSdk. substring(8 ). toInteger()
237
+ } else {
238
+ println " No installed SDKs found. Using default SDK " + defaultSdk
239
+ defaultSdk
240
+ }
241
+ } catch (any) {
242
+ println " Exception while determining highest SDK. Using default SDK " +
243
+ defaultSdk
244
+ defaultSdk
245
+ }
246
+ }
247
+
248
+ String latestBuildToolsAvailable (String defaultBuildTools ) {
249
+ try {
250
+ def buildToolsDir = new File (android. getSdkDirectory(). toString(), " build-tools" )
251
+ def buildToolsVersions = buildToolsDir. list([accept :{ d , f -> new File (d, f). isDirectory() }] as FilenameFilter ). sort { a , b -> b <=> a }
252
+ def latestBuildTools = buildToolsVersions[0 ]
253
+ if (latestBuildTools != null ) {
254
+ println " Using latest found build tools " + latestBuildTools
255
+ latestBuildTools
256
+ } else {
257
+ println " No installed build tools found. Using default build tools " +
258
+ defaultBuildTools
259
+ defaultBuildTools
260
+ }
261
+ } catch (any) {
262
+ println " Exception while determining latest build tools. Using default build tools " +
263
+ defaultBuildTools
264
+ defaultBuildTools
265
+ }
142
266
}
0 commit comments