build.gradle 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. apply plugin: 'com.android.application'
  2. android {
  3. compileSdkVersion 29
  4. sourceSets {
  5. main {
  6. manifest.srcFile 'AndroidManifest.xml'
  7. java.srcDirs = ['src/main/java']
  8. aidl.srcDirs = ['src/main/java']
  9. renderscript.srcDirs = ['src/main/java']
  10. res.srcDirs = ['res']
  11. assets.srcDirs = ['../assets']
  12. jniLibs.srcDirs = ['libs']
  13. }
  14. }
  15. packagingOptions {
  16. // Preventing from license violations (more or less):
  17. pickFirst 'META-INF/LICENSE.txt'
  18. pickFirst 'META-INF/LICENSE'
  19. pickFirst 'META-INF/license.txt'
  20. pickFirst 'META-INF/LGPL2.1'
  21. pickFirst 'META-INF/NOTICE.txt'
  22. pickFirst 'META-INF/NOTICE'
  23. pickFirst 'META-INF/notice.txt'
  24. // Excluding unnecessary meta-data:
  25. exclude 'META-INF/robovm/ios/robovm.xml'
  26. exclude 'META-INF/DEPENDENCIES.txt'
  27. exclude 'META-INF/DEPENDENCIES'
  28. exclude 'META-INF/dependencies.txt'
  29. }
  30. defaultConfig {
  31. applicationId 'com.simple.madqubies'
  32. minSdkVersion 19
  33. targetSdkVersion 29
  34. versionCode 1
  35. versionName "1.0"
  36. multiDexEnabled true
  37. }
  38. compileOptions {
  39. sourceCompatibility "8.0"
  40. targetCompatibility "8.0"
  41. coreLibraryDesugaringEnabled true
  42. }
  43. buildTypes {
  44. release {
  45. minifyEnabled false
  46. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  47. }
  48. }
  49. }
  50. repositories {
  51. // needed for AAPT2, may be needed for other tools
  52. google()
  53. }
  54. configurations { natives }
  55. dependencies {
  56. coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.10'
  57. implementation project(':core')
  58. implementation "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
  59. implementation "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
  60. natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
  61. natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a"
  62. natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
  63. natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"
  64. natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
  65. natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
  66. natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
  67. natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
  68. natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
  69. natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
  70. natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
  71. natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
  72. natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
  73. natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
  74. natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-armeabi"
  75. natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-armeabi-v7a"
  76. natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-arm64-v8a"
  77. natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-x86"
  78. natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-x86_64"
  79. }
  80. // Called every time gradle gets executed, takes the native dependencies of
  81. // the natives configuration, and extracts them to the proper libs/ folders
  82. // so they get packed with the APK.
  83. task copyAndroidNatives() {
  84. doFirst {
  85. file("libs/armeabi/").mkdirs()
  86. file("libs/armeabi-v7a/").mkdirs()
  87. file("libs/arm64-v8a/").mkdirs()
  88. file("libs/x86_64/").mkdirs()
  89. file("libs/x86/").mkdirs()
  90. configurations.getByName("natives").copy().files.each { jar ->
  91. def outputDir = null
  92. if(jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
  93. if(jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
  94. if(jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
  95. if(jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
  96. if(jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
  97. if(outputDir != null) {
  98. copy {
  99. from zipTree(jar)
  100. into outputDir
  101. include "*.so"
  102. }
  103. }
  104. }
  105. }
  106. }
  107. tasks.whenTaskAdded { packageTask ->
  108. if (packageTask.name.contains("package")) {
  109. packageTask.dependsOn 'copyAndroidNatives'
  110. }
  111. }
  112. task run(type: Exec) {
  113. def path
  114. def localProperties = project.file("../local.properties")
  115. if (localProperties.exists()) {
  116. Properties properties = new Properties()
  117. localProperties.withInputStream { instr ->
  118. properties.load(instr)
  119. }
  120. def sdkDir = properties.getProperty('sdk.dir')
  121. if (sdkDir) {
  122. path = sdkDir
  123. } else {
  124. path = "$System.env.ANDROID_HOME"
  125. }
  126. } else {
  127. path = "$System.env.ANDROID_HOME"
  128. }
  129. def adb = path + "/platform-tools/adb"
  130. commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.simple.madqubies/com.simple.madqubies.AndroidLauncher'
  131. }
  132. eclipse.project.name = appName + "-android"