169 lines
5.5 KiB
Groovy
169 lines
5.5 KiB
Groovy
// Loading nymeapp.properties. This file must be generated by the .pro file
|
|
Properties properties = new Properties()
|
|
properties.load(project.rootProject.file("nymeaapp.properties").newDataInputStream())
|
|
|
|
def nymeaAppRoot = properties.getProperty('nymeaAppRoot')
|
|
def useFirebase = properties.getProperty('useFirebase')
|
|
|
|
def nymeaVersionLines = file("${nymeaAppRoot}/version.txt").readLines().collect { it.trim() }.findAll { it }
|
|
def nymeaAppVersionName = nymeaVersionLines ? nymeaVersionLines[0] : "0.0.0"
|
|
def nymeaAppBaseVersionCode = nymeaVersionLines.size() > 1 ? nymeaVersionLines[1].toInteger() : 1
|
|
|
|
// Use ABI-aware version codes per Qt's legacy single-ABI Play Store guidance.
|
|
def abiVersionPrefixes = [
|
|
"armeabi-v7a": "132",
|
|
"arm64-v8a" : "164",
|
|
"x86" : "232",
|
|
"x86_64" : "264"
|
|
]
|
|
|
|
def qtTargetAbiListValue = project.hasProperty('qtTargetAbiList') ? qtTargetAbiList : ""
|
|
def targetAbiList = qtTargetAbiListValue.split(",").collect { it.trim() }.findAll { it }
|
|
def singleTargetAbi = targetAbiList.size() == 1 ? targetAbiList[0] : null
|
|
def computeAbiVersionCode = { abi, baseCode ->
|
|
def prefix = abiVersionPrefixes[abi]
|
|
return prefix ? Integer.parseInt("${prefix}${baseCode}") : baseCode
|
|
}
|
|
def nymeaDefaultVersionCode = computeAbiVersionCode(singleTargetAbi, nymeaAppBaseVersionCode)
|
|
|
|
println "Building Android package"
|
|
println "Package source root ${nymeaAppRoot}"
|
|
|
|
buildscript {
|
|
repositories {
|
|
jcenter()
|
|
google()
|
|
mavenCentral()
|
|
}
|
|
|
|
dependencies {
|
|
classpath 'com.android.tools.build:gradle:8.11.0'
|
|
classpath 'com.google.gms:google-services:4.3.8'
|
|
}
|
|
}
|
|
|
|
allprojects {
|
|
repositories {
|
|
google()
|
|
jcenter()
|
|
maven {
|
|
url "https://maven.google.com"
|
|
}
|
|
flatDir {
|
|
dirs nymeaAppRoot + "/3rdParty/android/firebase_cpp_sdk/libs/android/"
|
|
}
|
|
}
|
|
}
|
|
|
|
apply plugin: qtGradlePluginType
|
|
|
|
dependencies {
|
|
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
|
|
implementation 'org.reactivestreams:reactive-streams:1.0.3'
|
|
implementation 'io.reactivex.rxjava2:rxjava:2.2.0'
|
|
implementation 'androidx.core:core:1.16.0'
|
|
implementation 'androidx.activity:activity:1.10.1'
|
|
implementation 'androidx.fragment:fragment:1.8.8'
|
|
|
|
if ("${useFirebase}" == "true") {
|
|
implementation 'com.google.android.gms:play-services-base:18.1.0'
|
|
implementation 'com.google.firebase:firebase-messaging:22.0.0'
|
|
implementation 'com.google.firebase.messaging.cpp:firebase_messaging_cpp@aar'
|
|
}
|
|
|
|
constraints.implementation 'androidx.fragment:fragment:1.8.6'
|
|
}
|
|
|
|
if ("${useFirebase}" == "true") {
|
|
apply plugin: 'com.google.gms.google-services'
|
|
}
|
|
|
|
android {
|
|
/*******************************************************
|
|
* The following variables:
|
|
* - androidBuildToolsVersion,
|
|
* - androidCompileSdkVersion
|
|
* - qtAndroidDir - holds the path to qt android files
|
|
* needed to build any Qt application
|
|
* on Android.
|
|
* - qtGradlePluginType - whether to build an app or a library
|
|
*
|
|
* are defined in gradle.properties file. This file is
|
|
* updated by QtCreator and androiddeployqt tools.
|
|
* Changing them manually might break the compilation!
|
|
*******************************************************/
|
|
|
|
namespace 'io.guh.nymeaapp'
|
|
compileSdkVersion androidCompileSdkVersion
|
|
buildToolsVersion androidBuildToolsVersion
|
|
ndkVersion androidNdkVersion
|
|
|
|
// Extract native libraries from the APK
|
|
packagingOptions.jniLibs.useLegacyPackaging true
|
|
|
|
sourceSets {
|
|
main {
|
|
manifest.srcFile 'AndroidManifest.xml'
|
|
java.srcDirs = [qtAndroidDir + '/src', 'src', 'java']
|
|
aidl.srcDirs = [qtAndroidDir + '/src', 'src', 'aidl']
|
|
res.srcDirs = [qtAndroidDir + '/res', 'res']
|
|
resources.srcDirs = ['src']
|
|
renderscript.srcDirs = ['src']
|
|
assets.srcDirs = ['assets']
|
|
jniLibs.srcDirs = ['libs']
|
|
|
|
java.srcDirs = [
|
|
qt5AndroidDir + '/src',
|
|
nymeaAppRoot + '/nymea-app/platformintegration/android/java',
|
|
nymeaAppRoot + '/QtZeroConf/android',
|
|
'src',
|
|
'java']
|
|
|
|
if ("${useFirebase}" == "true") {
|
|
java.srcDirs += [nymeaAppRoot + '/nymea-app/platformintegration/android/java-firebase']
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
tasks.withType(JavaCompile) {
|
|
options.incremental = true
|
|
}
|
|
|
|
compileOptions {
|
|
sourceCompatibility JavaVersion.VERSION_1_8
|
|
targetCompatibility JavaVersion.VERSION_1_8
|
|
}
|
|
|
|
lintOptions {
|
|
abortOnError false
|
|
}
|
|
|
|
// Do not compress Qt binary resources file
|
|
aaptOptions {
|
|
noCompress 'rcc'
|
|
}
|
|
|
|
defaultConfig {
|
|
resConfigs "en", "de", "ko", "it", "nl", "es"
|
|
minSdkVersion = 23
|
|
targetSdkVersion = 36
|
|
ndk.abiFilters = targetAbiList
|
|
versionName nymeaAppVersionName
|
|
versionCode nymeaDefaultVersionCode
|
|
}
|
|
}
|
|
|
|
androidComponents {
|
|
onVariants(selector().all(), { variant ->
|
|
variant.outputs.forEach { output ->
|
|
def abiFilter = output.filters.find { it.filterType == com.android.build.api.variant.FilterConfiguration.FilterType.ABI }?.identifier
|
|
if (abiFilter != null) {
|
|
output.versionCode.set(computeAbiVersionCode(abiFilter, nymeaAppBaseVersionCode))
|
|
} else if (singleTargetAbi != null) {
|
|
output.versionCode.set(nymeaDefaultVersionCode)
|
|
}
|
|
}
|
|
})
|
|
}
|