[advanced Android] Android uses fluent

Time:2022-5-8

1. Rely on the fluent SDK in other directories
[advanced Android] Android uses fluent

plugins {
    id 'com.android.library'
    id 'kotlin-android'
}

//Rely on the fluent SDK in other directories
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 29

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles "consumer-rules.pro"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            versionNameSuffix kotlin_version
        }
        profile {
            versionNameSuffix kotlin_version
        }
        debug {
            versionNameSuffix kotlin_version
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}

flutter {
    source '../..'
}

dependencies {

    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.2.0'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'com.google.android.material:material:1.1.0'
    implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'], exclude: [])
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

2. Package only the architectures supported by fluent
[advanced Android] Android uses fluent

android {
    compileSdkVersion 29

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.flutter_app"
        minSdkVersion 16
        targetSdkVersion 29
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        ndk {
            Abifilters "arm64-v8a", "x86_64", "X84" // only the architectures supported by the fluent are packaged. The fluent does not have the so of the armeabi and armeabi-v7a architectures. X86 is to be compatible with the simulator
        }
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
        profile {
            applicationIdSuffix flutterVersionName
            versionNameSuffix flutterVersionName
        }
    }

    packagingOptions {
        //Ensure app and ASR_ Plugins all rely on lib / fluent So, merge does not conflict
        pickFirst 'lib/x86_64/libflutter.so'
        pickFirst 'lib/arm64-v8a/libflutter.so'
        pickFirst 'lib/x84/libflutter.so'
    }
}