DEADSOFTWARE

3430ac90888e3486f7f18a87bfd6d1687a5b876b
[cavedroid.git] / android / build.gradle
1 android {
2 buildToolsVersion "28.0.3"
3 compileSdkVersion 29
4 sourceSets {
5 main {
6 manifest.srcFile 'AndroidManifest.xml'
7 java.srcDirs = ['src']
8 aidl.srcDirs = ['src']
9 renderscript.srcDirs = ['src']
10 res.srcDirs = ['res']
11 assets.srcDirs = ['assets']
12 jniLibs.srcDirs = ['libs']
13 }
14 debug {
15 res.srcDirs = ['debug/res']
16 }
17 }
18 packagingOptions {
19 exclude 'META-INF/robovm/ios/robovm.xml'
20 }
21 defaultConfig {
22 applicationId "ru.deadsoftware.cavedroid"
23 minSdkVersion 14
24 targetSdkVersion 29
25 versionCode 10
26 versionName "alpha0.4"
27 }
28 applicationVariants.all { variant ->
29 variant.outputs.all {
30 outputFileName = "android-${versionName}.apk"
31 }
32 }
33 buildTypes {
34 release {
35 minifyEnabled false
36 }
37 debug {
38 applicationIdSuffix ".debug"
39 }
40 }
42 }
45 // called every time gradle gets executed, takes the native dependencies of
46 // the natives configuration, and extracts them to the proper libs/ folders
47 // so they get packed with the APK.
48 task copyAndroidNatives {
49 doFirst {
50 file("libs/armeabi/").mkdirs()
51 file("libs/armeabi-v7a/").mkdirs()
52 file("libs/arm64-v8a/").mkdirs()
53 file("libs/x86_64/").mkdirs()
54 file("libs/x86/").mkdirs()
56 configurations.natives.files.each { jar ->
57 def outputDir = null
58 if (jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
59 if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
60 if(jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
61 if(jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
62 if(jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
63 if(outputDir != null) {
64 copy {
65 from zipTree(jar)
66 into outputDir
67 include "*.so"
68 }
69 }
70 }
71 }
72 }
74 tasks.whenTaskAdded { packageTask ->
75 if (packageTask.name.contains("package")) {
76 packageTask.dependsOn 'copyAndroidNatives'
77 }
78 }
80 task run(type: Exec) {
81 def path
82 def localProperties = project.file("../local.properties")
83 if (localProperties.exists()) {
84 Properties properties = new Properties()
85 localProperties.withInputStream { instr ->
86 properties.load(instr)
87 }
88 def sdkDir = properties.getProperty('sdk.dir')
89 if (sdkDir) {
90 path = sdkDir
91 } else {
92 path = "$System.env.ANDROID_HOME"
93 }
94 } else {
95 path = "$System.env.ANDROID_HOME"
96 }
98 def adb = path + "/platform-tools/adb"
99 commandLine "$adb", 'shell', 'am', 'start', '-n', 'ru.deadsoftware.cavedroid/ru.deadsoftware.cavedroid.AndroidLauncher'