build.gradle 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. def buildWithCMake = project.hasProperty('BUILD_WITH_CMAKE');
  2. def buildAsLibrary = project.hasProperty('BUILD_AS_LIBRARY');
  3. def buildAsApplication = !buildAsLibrary
  4. if (buildAsApplication) {
  5. apply plugin: 'com.android.application'
  6. }
  7. else {
  8. apply plugin: 'com.android.library'
  9. }
  10. android {
  11. if (buildAsApplication) {
  12. namespace "org.libsdl.app"
  13. }
  14. compileSdkVersion 34
  15. defaultConfig {
  16. minSdkVersion 19
  17. targetSdkVersion 34
  18. versionCode 1
  19. versionName "1.0"
  20. externalNativeBuild {
  21. ndkBuild {
  22. arguments "APP_PLATFORM=android-19"
  23. // abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
  24. abiFilters 'arm64-v8a'
  25. }
  26. cmake {
  27. arguments "-DANDROID_PLATFORM=android-19", "-DANDROID_STL=c++_static"
  28. // abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
  29. abiFilters 'arm64-v8a'
  30. }
  31. }
  32. }
  33. buildTypes {
  34. release {
  35. minifyEnabled false
  36. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  37. }
  38. }
  39. applicationVariants.all { variant ->
  40. tasks["merge${variant.name.capitalize()}Assets"]
  41. .dependsOn("externalNativeBuild${variant.name.capitalize()}")
  42. }
  43. if (!project.hasProperty('EXCLUDE_NATIVE_LIBS')) {
  44. sourceSets.main {
  45. jniLibs.srcDir 'libs'
  46. }
  47. externalNativeBuild {
  48. if (buildWithCMake) {
  49. cmake {
  50. path 'jni/CMakeLists.txt'
  51. }
  52. } else {
  53. ndkBuild {
  54. path 'jni/Android.mk'
  55. }
  56. }
  57. }
  58. }
  59. lint {
  60. abortOnError false
  61. }
  62. if (buildAsLibrary) {
  63. libraryVariants.all { variant ->
  64. variant.outputs.each { output ->
  65. def outputFile = output.outputFile
  66. if (outputFile != null && outputFile.name.endsWith(".aar")) {
  67. def fileName = "org.libsdl.app.aar";
  68. output.outputFile = new File(outputFile.parent, fileName);
  69. }
  70. }
  71. }
  72. }
  73. }
  74. dependencies {
  75. implementation fileTree(include: ['*.jar'], dir: 'libs')
  76. }