build.gradle 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. android {
  2. buildToolsVersion "29.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. }
  15. packagingOptions {
  16. exclude 'META-INF/robovm/ios/robovm.xml'
  17. }
  18. defaultConfig {
  19. applicationId "com.pjl.kursovaya"
  20. minSdkVersion 14
  21. targetSdkVersion 29
  22. versionCode 1
  23. versionName "1.0"
  24. }
  25. buildTypes {
  26. release {
  27. minifyEnabled true
  28. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  29. }
  30. }
  31. }
  32. // called every time gradle gets executed, takes the native dependencies of
  33. // the natives configuration, and extracts them to the proper libs/ folders
  34. // so they get packed with the APK.
  35. task copyAndroidNatives {
  36. doFirst {
  37. file("libs/armeabi/").mkdirs()
  38. file("libs/armeabi-v7a/").mkdirs()
  39. file("libs/arm64-v8a/").mkdirs()
  40. file("libs/x86_64/").mkdirs()
  41. file("libs/x86/").mkdirs()
  42. configurations.natives.copy().files.each { jar ->
  43. def outputDir = null
  44. if (jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
  45. if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
  46. if(jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
  47. if(jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
  48. if(jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
  49. if(outputDir != null) {
  50. copy {
  51. from zipTree(jar)
  52. into outputDir
  53. include "*.so"
  54. }
  55. }
  56. }
  57. }
  58. }
  59. tasks.whenTaskAdded { packageTask ->
  60. if (packageTask.name.contains("package")) {
  61. packageTask.dependsOn 'copyAndroidNatives'
  62. }
  63. }
  64. task run(type: Exec) {
  65. def path
  66. def localProperties = project.file("../local.properties")
  67. if (localProperties.exists()) {
  68. Properties properties = new Properties()
  69. localProperties.withInputStream { instr ->
  70. properties.load(instr)
  71. }
  72. def sdkDir = properties.getProperty('sdk.dir')
  73. if (sdkDir) {
  74. path = sdkDir
  75. } else {
  76. path = "$System.env.ANDROID_HOME"
  77. }
  78. } else {
  79. path = "$System.env.ANDROID_HOME"
  80. }
  81. def adb = path + "/platform-tools/adb"
  82. commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.pjl.kursovaya/com.pjl.kursovaya.AndroidLauncher'
  83. }
  84. eclipse.project.name = appName + "-android"