/ android / build.gradle
build.gradle
  1  android {
  2      namespace "xyz.r0r5chach.dermy_app"
  3      compileSdk 35
  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      }
 16      packagingOptions {
 17          exclude 'META-INF/robovm/ios/robovm.xml'
 18          exclude 'META-INF/native-image/org.mongodb/bson/native-image.properties'
 19      }
 20      defaultConfig {
 21          applicationId "xyz.r0r5chach.dermy_app"
 22          minSdkVersion 26
 23          targetSdkVersion 35
 24          versionCode 1
 25          versionName "1.0"
 26      }
 27      buildTypes {
 28          release {
 29              minifyEnabled true
 30              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
 31          }
 32      }
 33      buildFeatures {
 34          renderScript true
 35          aidl true
 36      }
 37      compileOptions {
 38        sourceCompatibility = JavaVersion.VERSION_1_8
 39        targetCompatibility = JavaVersion.VERSION_1_8
 40        coreLibraryDesugaringEnabled false
 41      }
 42      kotlinOptions {
 43        jvmTarget = "1.8"
 44      }
 45  }
 46  
 47  dependencies {
 48    implementation "androidx.room:room-ktx:$roomVersion"
 49    implementation "androidx.room:room-runtime:$roomVersion"
 50    ksp "androidx.room:room-compiler:$roomVersion"
 51  }
 52  
 53  // called every time gradle gets executed, takes the native dependencies of
 54  // the natives configuration, and extracts them to the proper libs/ folders
 55  // so they get packed with the APK.
 56  tasks.register('copyAndroidNatives') {
 57      doFirst {
 58          file("libs/armeabi-v7a/").mkdirs()
 59          file("libs/arm64-v8a/").mkdirs()
 60          file("libs/x86_64/").mkdirs()
 61          file("libs/x86/").mkdirs()
 62  
 63          configurations.natives.copy().files.each { jar ->
 64              def outputDir = null
 65              if (jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
 66              if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
 67              if (jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
 68              if (jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
 69              if (outputDir != null) {
 70                  copy {
 71                      from zipTree(jar)
 72                      into outputDir
 73                      include "*.so"
 74                  }
 75              }
 76          }
 77      }
 78  }
 79  
 80  tasks.matching { it.name.contains("merge") && it.name.contains("JniLibFolders") }.configureEach { packageTask ->
 81      packageTask.dependsOn 'copyAndroidNatives'
 82  }
 83  
 84  tasks.register('run', Exec) {
 85      def path
 86      def localProperties = project.file("../local.properties")
 87      if (localProperties.exists()) {
 88          Properties properties = new Properties()
 89          localProperties.withInputStream { instr ->
 90              properties.load(instr)
 91          }
 92          def sdkDir = properties.getProperty('sdk.dir')
 93          if (sdkDir) {
 94              path = sdkDir
 95          } else {
 96              path = "$System.env.ANDROID_HOME"
 97          }
 98      } else {
 99          path = "$System.env.ANDROID_HOME"
100      }
101  
102      def adb = path + "/platform-tools/adb"
103      commandLine "$adb", 'shell', 'am', 'start', '-n', 'xyz.r0r5chach.dermy_app/xyz.r0r5chach.dermy_app.MainActivity'
104  }
105  
106  eclipse.project.name = appName + "-android"