buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
    //     classpath 'com.android.tools.build:gradle:3.6.0' // for Qt 5.15.2
        classpath 'com.android.tools.build:gradle:7.0.4' // for Qt 5.15.11
    }
}

repositories {
    google()
    jcenter()
}

apply plugin: 'com.android.application'

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
}

android {
    /*******************************************************
     * The following variables:
     * - androidBuildToolsVersion,
     * - androidCompileSdkVersion
     * - qt5AndroidDir - holds the path to qt android files
     *                   needed to build any Qt application
     *                   on Android.
     *
     * are defined in gradle.properties file. This file is
     * updated by QtCreator and androiddeployqt tools.
     * Changing them manually might break the compilation!
     *******************************************************/
	// Bullshit! We have to do this explicetely as Qt 5.15.11 throw errors not finding when no gradle.properties files exist

    compileSdkVersion 31 //androidCompileSdkVersion.toInteger()

    // buildToolsVersion '28.0.3' // for 5.15.2
    buildToolsVersion '31.0.0' // androidBuildToolsVersion.toString() // for 5.15.11

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
            aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
            res.srcDirs = [qt5AndroidDir + '/res', 'res']
            resources.srcDirs = ['resources']
            renderscript.srcDirs = ['src']
            assets.srcDirs = ['assets']
            jniLibs.srcDirs = ['libs']
            // jniLibs.srcDirs = ['src/main/jniLibs']

       }
    }

    tasks.withType(JavaCompile) {
        options.incremental = true
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }

    // Do not compress Qt binary resources file
    aaptOptions {
        noCompress 'rcc'
    }

    defaultConfig {
        resConfig "en"
        minSdkVersion = 25
        targetSdkVersion = 29
    }
}
