В моем файле Gradle у меня есть следующие настройки, и они работают хорошо, но я не могу сделать это для CI в Gitlab:
Код: Выделить всё
plugins {
id("com.android.application")
id("kotlin-android")
id("dev.flutter.flutter-gradle-plugin")
}
fun generateBuildVersion(): String {
val date = Date()
val sdf = SimpleDateFormat("yyyy.MM.dd.HH.mm", Locale.US)
sdf.timeZone = TimeZone.getTimeZone("Europe/Kyiv")
val buildDateTime = sdf.format(date)
return if (gradle.startParameter.taskNames.any {
it.contains("release", ignoreCase = true)
}) {
"$buildDateTime-production"
} else {
"$buildDateTime-dev"
}
}
val buildVersion = generateBuildVersion()
android {
namespace = "com.example.player"
compileSdk = flutter.compileSdkVersion
ndkVersion = "27.0.12077973"
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
}
defaultConfig {
applicationId = "com.example.player"
minSdk = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion
versionCode = SimpleDateFormat("yyyyMMddHH", Locale.US)
.apply { timeZone = TimeZone.getTimeZone("Europe/Kyiv") }
.format(Date()).toInt()
versionName = buildVersion
}
applicationVariants.all {
outputs.all {
(this as com.android.build.gradle.internal.api.BaseVariantOutputImpl).outputFileName =
"$buildVersion.apk"
}
this.mergeAssetsProvider.configure {
doLast {
val buildInfo = """
{
"version": "$buildVersion"
}
""".trimIndent()
val assetsDir = outputDir.get().asFile
val versionFile = File(assetsDir, "build_version.json")
versionFile.writeText(buildInfo)
println("✅ APK: $buildVersion")
}
}
}
buildTypes {
release {
signingConfig = signingConfigs.getByName("debug")
}
}
}
flutte/r {
source = "../.."
}
Код: Выделить всё
// This code in yaml creates simple apk with name: "build-apk"
stages:
- build
# Use Flutter 3.27 or later which includes Dart 3.8+
image: ghcr.io/cirruslabs/flutter:3.38.7
cache:
key: flutter-cache
paths:
- .pub-cache
- build
before_script:
- flutter --version
- flutter doctor -v
build-apk:
stage: build
script:
- flutter pub get
- flutter build apk --debug
artifacts:
name: "flutter-debug-apk-$CI_COMMIT_SHORT_SHA"
paths:
- build/app/outputs/flutter-apk/*.apk
expire_in: 30 days
rules:
- if: '$CI_PIPELINE_SOURCE == "push"'

Подробнее здесь: https://stackoverflow.com/questions/798 ... er-project
Мобильная версия