build.gradle 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. buildscript {
  2. repositories {
  3. mavenCentral()
  4. google()
  5. }
  6. }
  7. apply plugin: 'com.android.application'
  8. android {
  9. namespace "xyz.prismix"
  10. compileSdk 34
  11. sourceSets {
  12. main {
  13. manifest.srcFile 'AndroidManifest.xml'
  14. java.setSrcDirs(['src/main/java'])
  15. aidl.setSrcDirs(['src/main/java'])
  16. renderscript.setSrcDirs(['src/main/java'])
  17. res.setSrcDirs(['res'])
  18. assets.setSrcDirs(['../assets'])
  19. jniLibs.setSrcDirs(['libs'])
  20. }
  21. }
  22. packagingOptions {
  23. resources {
  24. excludes += ['META-INF/robovm/ios/robovm.xml', 'META-INF/DEPENDENCIES.txt', 'META-INF/DEPENDENCIES',
  25. 'META-INF/dependencies.txt', '**/*.gwt.xml']
  26. pickFirsts += ['META-INF/LICENSE.txt', 'META-INF/LICENSE', 'META-INF/license.txt', 'META-INF/LGPL2.1',
  27. 'META-INF/NOTICE.txt', 'META-INF/NOTICE', 'META-INF/notice.txt']
  28. }
  29. }
  30. defaultConfig {
  31. applicationId 'xyz.prismix'
  32. minSdkVersion 19
  33. targetSdkVersion 34
  34. versionCode 1
  35. versionName "1.0"
  36. multiDexEnabled true
  37. }
  38. compileOptions {
  39. sourceCompatibility "8"
  40. targetCompatibility "8"
  41. coreLibraryDesugaringEnabled true
  42. }
  43. buildTypes {
  44. release {
  45. minifyEnabled true
  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:2.0.4'
  57. implementation "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
  58. implementation "com.github.MrStahlfelge.gdx-websockets:common:$websocketVersion"
  59. implementation project(':core')
  60. natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a"
  61. natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
  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-bullet-platform:$gdxVersion:natives-arm64-v8a"
  65. natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-armeabi-v7a"
  66. natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-x86"
  67. natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-x86_64"
  68. natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
  69. natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
  70. natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
  71. natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
  72. natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
  73. natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
  74. natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
  75. natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
  76. }
  77. // Called every time gradle gets executed, takes the native dependencies of
  78. // the natives configuration, and extracts them to the proper libs/ folders
  79. // so they get packed with the APK.
  80. tasks.register('copyAndroidNatives') {
  81. doFirst {
  82. file("libs/armeabi-v7a/").mkdirs()
  83. file("libs/arm64-v8a/").mkdirs()
  84. file("libs/x86_64/").mkdirs()
  85. file("libs/x86/").mkdirs()
  86. configurations.natives.copy().files.each { jar ->
  87. def outputDir = null
  88. if(jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
  89. if(jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
  90. if(jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
  91. if(jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
  92. if(outputDir != null) {
  93. copy {
  94. from zipTree(jar)
  95. into outputDir
  96. include "*.so"
  97. }
  98. }
  99. }
  100. }
  101. }
  102. tasks.matching { it.name.contains("merge") && it.name.contains("JniLibFolders") }.configureEach { packageTask ->
  103. packageTask.dependsOn 'copyAndroidNatives'
  104. }
  105. tasks.register('run', Exec) {
  106. def path
  107. def localProperties = project.file("../local.properties")
  108. if (localProperties.exists()) {
  109. Properties properties = new Properties()
  110. localProperties.withInputStream { instr ->
  111. properties.load(instr)
  112. }
  113. def sdkDir = properties.getProperty('sdk.dir')
  114. if (sdkDir) {
  115. path = sdkDir
  116. } else {
  117. path = "$System.env.ANDROID_SDK_ROOT"
  118. }
  119. } else {
  120. path = "$System.env.ANDROID_SDK_ROOT"
  121. }
  122. def adb = path + "/platform-tools/adb"
  123. commandLine "$adb", 'shell', 'am', 'start', '-n', 'xyz.prismix/xyz.prismix.android.AndroidLauncher'
  124. }
  125. eclipse.project.name = appName + "-android"