Код: Выделить всё
e: file:///C:/Users/Zaria/new_sorry_tally/android/app/build.gradle.kts:70:29: Type mismatch: inferred type is Unit but Boolean was expected
e: file:///C:/Users/Zaria/new_sorry_tally/android/app/build.gradle.kts:80:13: Expected a value of type Boolean
e: file:///C:/Users/Zaria/new_sorry_tally/android/app/build.gradle.kts:80:20: Unresolved reference: outputFileName
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\Zaria\new_sorry_tally\android\app\build.gradle.kts' line: 70
* What went wrong:
Script compilation errors:
Line 70: variant.outputs.all { output ->
^ Type mismatch: inferred type is Unit but Boolean was expected
Line 80: output.outputFileName = outputFile.name
^ Expected a value of type Boolean
Line 80: output.outputFileName = outputFile.name
^ Unresolved reference: outputFileName
< /code>
import com.android.build.gradle.api.ApplicationVariant
import java.io.File
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("dev.flutter.flutter-gradle-plugin")
id("com.google.gms.google-services") // Google services plugin for Firebase
id("com.google.firebase.crashlytics") // Firebase Crashlytics plugin
}
android {
namespace = "com.zaria.new_sorry_tally"
compileSdk = 35
ndkVersion = "27.0.12077973"
defaultConfig {
applicationId = "com.zaria.new_sorry_tally"
minSdk = 21
targetSdk = 35
versionCode = 1
versionName = "1.0"
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
buildTypes {
getByName("debug") {
isMinifyEnabled = false
}
getByName("release") {
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
signingConfig = signingConfigs.getByName("release")
}
}
dependencies {
// Material Design and AppCompat
implementation("com.google.android.material:material:1.11.0")
implementation("androidx.appcompat:appcompat:1.6.1")
// Firebase SDKs
implementation("com.google.firebase:firebase-analytics:21.6.0")
implementation("com.google.firebase:firebase-firestore:24.10.1")
implementation("com.google.firebase:firebase-crashlytics:18.6.5")
// Play Services for Firebase and Analytics
implementation("com.google.android.gms:play-services-measurement-api:21.6.0")
implementation("com.google.android.gms:play-services-measurement-impl:21.6.0")
}
}
// Apply the Google services plugin at the end
apply(plugin = "com.google.gms.google-services")
// After evaluate block for customizing APK output names
afterEvaluate {
android.applicationVariants.all { variant ->
variant.outputs.all { output ->
val outputFileName = if (variant.buildType.name == "debug") {
"app-debug.apk"
} else {
"app-release.apk"
}
// Correct way to modify APK output name in newer AGP versions
val outputFile = File(buildDir, "outputs/apk/${variant.buildType.name}/$outputFileName")
// Set the output file name correctly for newer AGP versions
output.outputFile = outputFile
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... -build-apk