build.gradle 3.7 KB

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