0

我正在升级 Gradle,因为 Android Studio 提示我这样做,但在此过程中,我收到错误,我无法弄清楚问题是什么,而且我也没有看到任何构建变体。

我在底部附上了完整的错误。

这些是我的 Gradle 文件

有关如何解决此问题的任何建议,请

在此先感谢

build.gradle.kts(项目:app-android)

   plugins {
    id("com.android.application").apply(false)

    kotlin("android").apply(false)
    kotlin("android.extensions").apply(false)
    kotlin("kapt").apply(false)
    id("kotlinx-serialization").apply(false)
    id("com.google.gms.google-services").apply(false)
    id("com.google.firebase.crashlytics").apply(false)
}

allprojects {
    repositories {
        google()
        mavenCentral()
        //jcenter()
        maven("https://jitpack.io" )
        maven("https://sdk.uxcam.com/android/" )
    }
}

buildscript {
    val kotlinVersion by extra("1.5.21")
    dependencies {
        "classpath"("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
        classpath("com.android.tools.build:gradle:7.0.3")
    }
}

tasks.register<Delete>("clean") {
    delete(rootProject.buildDir)
}

build.gradle.kts (:core)

android {
    compileSdk = 30
    buildToolsVersion = "30.0.3"

    buildFeatures {
        dataBinding = true
        viewBinding = true
    }

    defaultConfig {
        applicationId = "io.o.android"

        manifestPlaceholders["MapAPIKey"] = secureProp.getProperty("MAPS_API_KEY")

        minSdk =23
        targetSdk = 30

        // Only get the FirebaseUI translations relevant to our app
        // (see https://github.com/firebase/FirebaseUI-Android/tree/master/auth)
        resConfigs("en")

        // Export the local DB schema to the dbSchemas dir
        // (see https://developer.android.com/training/data-storage/room/migrating-db-versions.html)
        javaCompileOptions {
            annotationProcessorOptions {
                arguments += mapOf("room.schemaLocation" to "$projectDir/dbSchemas")
            }
        }

        kotlinOptions {
            freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
        }
        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
        // Clear the app's state between tests
        testInstrumentationRunnerArgument("clearPackageData", "true")
    }

    sourceSets {
        all {
            java.srcDir("src/$name/kotlin")
        }
        getByName("androidTest") {
            // Add the DB schemas dir as a test asset so we can test DB migrations
            // (see https://developer.android.com/training/data-storage/room/migrating-db-versions.html)
            assets.srcDir(files("$projectDir/dbSchemas"))
        }
    }

    val debug = "debug"
    val release = "release"

    signingConfigs {
        create(release) {
            keyAlias = keystoreProp["keyAlias"] as? String
            keyPassword = keystoreProp["keyPassword"] as? String
            storeFile = file(keystoreProp["storeFile"]!!)
            storePassword = keystoreProp["storePassword"] as? String
        }
    }

    buildTypes {
        getByName(debug) {
            // We use the "version name suffix" instead of the "application ID suffix" so that we don't have to create
            // multiple apps in Firebase
            versionNameSuffix = "-$debug"
        }
        getByName(release) {
            signingConfig = signingConfigs.getByName("debug")

            isMinifyEnabled = true
            isShrinkResources = true
            proguardFiles(getDefaultProguardFile("proguard-android.txt"), file("proguard-rules.pro"))
        }
    }

    flavorDimensions("brand", "type", "server")

    // We add different app ID suffix so we don't install different flavors overriding others, which might lead to
    // data issues in the device and unpredictable errors
    productFlavors {
        create("o") {
            dimension = "brand"

            applicationId = "io.o.android"
            manifestPlaceholders["DeepLinkBrand"] = "/o"
        }
        create("evc") {
            dimension = "brand"

            applicationId = "io.o.evc.android"
            manifestPlaceholders["DeepLinkBrand"] = "/evc"
        }
        create("home") {
            dimension = "type"

            versionCode = 1210100
            versionName = "1.21.0"
        }
        create("public") {
            dimension = "type"

            versionCode = 1200101
            versionName = "1.20.1"
        }
        create("local") {
            dimension = "server"

            applicationIdSuffix = ".local"
            manifestPlaceholders["ClearTextEnabled"] = true
        }
        create("dev") {
            dimension = "server"

            applicationIdSuffix = ".dev"
            manifestPlaceholders["ClearTextEnabled"] = false
        }
        create("prod") {
            dimension = "server"

            manifestPlaceholders["ClearTextEnabled"] = false
        }
    }

    applicationVariants.all {
        val mergedFlavor = (mergedFlavor as com.android.build.gradle.internal.core.MergedFlavor)
        mergedFlavor.applicationIdSuffix = ""
        when(name) {
            "oHomeProdRelease" -> mergedFlavor.applicationId = "io.o.android"
            "oHomeProdDebug" -> mergedFlavor.applicationId = "io.o.android"
            "oHomeDevRelease" -> mergedFlavor.applicationId = "io.o.android.dev"
            "oHomeDevDebug" -> mergedFlavor.applicationId = "io.o.android.dev"
            "oHomeLocalRelease" -> mergedFlavor.applicationId = "io.o.android.local"
            "oHomeLocalDebug" -> mergedFlavor.applicationId = "io.o.android.local"
            "oPublicProdRelease" -> mergedFlavor.applicationId = "io.o.android.public"
            "oPublicProdDebug" -> mergedFlavor.applicationId = "io.o.android.public"
            "oPublicDevRelease" -> mergedFlavor.applicationId = "io.o.android.public.dev"
            "oPublicDevDebug" -> mergedFlavor.applicationId = "io.o.android.public.dev"
            "oPublicLocalRelease" -> mergedFlavor.applicationId = "io.o.android.public.local"
            "oPublicLocalDebug" -> mergedFlavor.applicationId = "io.o.android.public.local"
            "evcPublicProdRelease" -> mergedFlavor.applicationId = "io.o.evc.android"
            "evcPublicProdDebug" -> mergedFlavor.applicationId = "io.o.evc.android"
            "evcPublicDevRelease" -> mergedFlavor.applicationId = "io.o.evc.android.dev"
            "evcPublicDevDebug" -> mergedFlavor.applicationId = "io.o.evc.android.dev"
            "evcPublicLocalRelease" -> mergedFlavor.applicationId = "io.o.evc.android.local"
            "evcPublicLocalDebug" -> mergedFlavor.applicationId = "io.o.evc.android.local"
            else -> {
                println("configureVariant: $name")
            }
        }
    }

    applicationVariants.all(object : Action<ApplicationVariant> {
        override fun execute(variant: ApplicationVariant) {
            val appName = when (variant.name) {
                "oHomeProdRelease" -> {
                    "O"
                }
                "oPublicProdRelease" -> {
                    "Park & Charge"
                }
                "evcPublicProdRelease" -> {
                    "EVC"
                }
                else -> {
                    variant.name
                }
            }
            variant.resValue("string", "app_name", appName)

            renameApk(apkVariant = variant)
        }
    })

    testVariants.all(object : Action<TestVariant> {
        override fun execute(variant: TestVariant) {
            renameApk(apkVariant = variant)
        }
    })

    // Enable the Test Orchestrator (see https://developer.android.com/training/testing/junit-runner.html#using-android-test-orchestrator)
    testOptions { execution = "ANDROIDX_TEST_ORCHESTRATOR" }

    // Run instrumented tests on the release build
//    testBuildType = release

    // This fixes a compilation error caused by adding Coroutines lib twice (see https://github.com/Kotlin/kotlinx.coroutines/issues/1064)
    // TODO: Remove when this is no longer happening
    packagingOptions { exclude("META-INF/*") }

    lintOptions { isAbortOnError = false }
    //dynamicFeatures = mutableSetOf()
}

配置项目 ':core' 时出现问题。> 未能通知项目评估监听器。> 无法查询该属性的值,因为项目 ':core' 的配置尚未完成。> 未找到名称为“oHomeLocalDebug”的 KotlinJvmAndroidCompilation。

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':core'.
    at org.gradle.configuration.project.LifecycleProjectEvaluator.wrapException(LifecycleProjectEvaluator.java:75)
    at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:68)
    at org.gradle.configuration.project.LifecycleProjectEvaluator.access$400(LifecycleProjectEvaluator.java:51)
    at org.gradle.configuration.project.LifecycleProjectEvaluator$NotifyAfterEvaluate.run(LifecycleProjectEvaluator.java:195)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:56)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$run$1(DefaultBuildOperationExecutor.java:74)
    at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.runWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:45)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:74)
    at org.gradle.configuration.project.LifecycleProjectEvaluator$EvaluateProject.lambda$run$0(LifecycleProjectEvaluator.java:105)
    at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.lambda$applyToMutableState$0(DefaultProjectStateRegistry.java:280)
    at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.lambda$withProjectLock$3(DefaultProjectStateRegistry.java:340)
    at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:213)
    at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.withProjectLock(DefaultProjectStateRegistry.java:340)
    at 
4

0 回答 0