uniffi-rs-fullstack-examples/hello/platforms/android/UniffiRustExample/app/build.gradle

81 lines
2.5 KiB
Groovy

plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
apply plugin: 'org.mozilla.rust-android-gradle.rust-android'
cargo {
prebuiltToolchains = true
targetDirectory = "$projectDir/../../../../../target" // because of workspace
module = "$projectDir/../../../.." // Or whatever directory contains your Cargo.toml
libname = "hello" // Or whatever matches Cargo.toml's [package] name.
pythonCommand = 'python3'
profile = 'debug'
targets = ["x86_64", "arm64", "arm", "x86"]
extraCargoBuildArguments = ["--lib"]
verbose = true
}
android {
compileSdk 31
// https://developer.android.com/studio/projects/configure-agp-ndk
ndkPath System.getenv("ANDROID_NDK_HOME")
defaultConfig {
applicationId "com.demo.mobile.uniffirustexample"
minSdk 23
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
}
namespace 'com.example.mobile.demo.uniffirustexample'
}
dependencies {
implementation "net.java.dev.jna:jna:5.7.0@aar"
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.navigation:navigation-fragment-ktx:2.4.1'
implementation 'androidx.navigation:navigation-ui-ktx:2.4.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
afterEvaluate {
// The `cargoBuild` task isn't available until after evaluation.
android.applicationVariants.all { variant ->
def productFlavor = ""
variant.productFlavors.each {
productFlavor += "${it.name.capitalize()}"
}
def buildType = "${variant.buildType.name.capitalize()}"
tasks["generate${productFlavor}${buildType}Assets"].dependsOn(tasks["cargoBuild"])
}
}