apply plugin: 'com.android.application'
apply plugin: 'org.jetbrains.kotlin.android'

android {
    namespace 'aicare.net.cn.sdk.ailinksdkdemoandroid'
    buildFeatures { buildConfig true }
    compileSdkVersion app_compileSdk
    defaultConfig {
        applicationId "aicare.net.cn.sdk.ailinksdkdemoandroid"
        minSdkVersion app_minSdk
        targetSdkVersion app_targetSdk
        versionName "1.16.21"
        versionCode getVersionCodeNumber(versionName)
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }

    repositories {
        flatDir {
            dirs project(':otalibrary').file('libs')
            dirs 'libs'
        }
    }
    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
    }

    kotlinOptions {
        jvmTarget = '11'
    }
    buildFeatures {
        viewBinding true
    }

}
static def getVersionCodeNumber(String versionName) {
    //1.49.13_beta05
    int code=0
    if (versionName!=null){
        String versionCodeStr=versionName+"80"
        if (versionName.contains("_")){
            String[] versionStr=versionName.split("_")
            versionCodeStr=versionStr[0]+"."+versionStr[1].substring(4)
        }
        String[] versionCodes=versionCodeStr.split("\\.")
        for(int i=0;i<versionCodes.length;i++){
            String version=versionCodes[i]
            if (version.length()<=1){
                version="0"+version;
            }
            versionCodes[i]=version
        }
        String versionAllStr=""
        for (String version:versionCodes){
            versionAllStr+=version
        }
        code= (versionAllStr).toInteger()
    }
    return code
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "androidx.appcompat:appcompat:$appcompat_version"
    implementation "androidx.core:core-ktx:$core_ktx_version"
    implementation "androidx.activity:activity:1.8.0"
    testImplementation 'junit:junit:4.12'
    implementation 'androidx.cardview:cardview:1.0.0'
    //https://jitpack.io/#elinkthings/AILinkSDKRepositoryAndroid
    implementation 'com.github.elinkthings:AILinkSDKRepositoryAndroid:1.15.04'//蓝牙核心库

    //https://jitpack.io/#elinkthings/AILinkSDKParsingLibraryAndroid
    implementation 'com.github.elinkthings:AILinkSDKParsingLibraryAndroid:1.9.13'//蓝牙解析库,需要依赖核心库
    implementation 'androidx.recyclerview:recyclerview:1.3.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
//    implementation project(path: ':otalibrary')
    implementation 'androidx.recyclerview:recyclerview:1.3.2'
    api 'com.squareup.retrofit2:converter-gson:2.7.2'
//    implementation (name: 'modulelibrary-release', ext: 'aar')
}
