gpt4 book ai didi

android - 使用 android gradle 插件版本 7.0.0-alpha15 时无法使用 kotlin-gradle-dsl 脚本

转载 作者:行者123 更新时间:2023-12-04 11:29:51 29 4
gpt4 key购买 nike

我将我的 Android Studio Canary 更新到版本 2020 3.1 Canary 15这还要求我将我的 AGP 更新到版本 7.0.0-alpha15 .我正在使用 kotlin-gradle-dsl作为我的 gradle 构建文件,现在无法使用 Unresolved reference 构建.
请注意,在更新到版本 7.0.0-alpha15 之前,gradle 已成功构建。 .
我的应用等级build.gradle.kts如下:

import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties

plugins {
id("com.android.application")
id("kotlin-android")
id("kotlin-kapt")
id("dagger.hilt.android.plugin")
}

val apiKey: String = gradleLocalProperties(rootDir).getProperty("API_KEY")

android {
compileSdkVersion(30)
buildToolsVersion("30.0.3")

defaultConfig {
applicationId("com.training.flicker")
minSdkVersion(21)
targetSdkVersion(30)
versionCode(1)
versionName = "1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}

buildConfigField("String", "API_KEY", apiKey)
}

buildTypes {
release {
minifyEnabled(false)
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
useIR = true
}

buildFeatures.compose = true
composeOptions.kotlinCompilerExtensionVersion = Version.compose
}

dependencies {

implementation(Android.coreKtx)
implementation(Android.appCompat)
implementation(Android.material)

implementation(Retrofit.retrofit)
implementation(Retrofit.convertorGson)

implementation(Hilt.hiltAndroid)
kapt(Hilt.hiltKapt)

implementation(Compose.material)
implementation(Compose.tooling)
implementation(Compose.ui)
implementation(Compose.activity)

implementation(Coroutines.android)

implementation(Arch.runtime)
implementation(Arch.viewModel)
implementation(Arch.liveData)

testImplementation(Test.junit)
androidTestImplementation(Test.androidJunit)
androidTestImplementation(Test.espressoCore)
androidTestImplementation(Test.composeUi)
}
这是我得到的错误
Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: 
public inline operator fun <T : Any, C : NamedDomainObjectContainer<TypeVariable(T)>> TypeVariable(C).invoke(configuration: Action<NamedDomainObjectContainerScope<TypeVariable(T)>>): TypeVariable(C) defined in org.gradle.kotlin.dsl
public operator fun <T> Closure<TypeVariable(T)>.invoke(): TypeVariable(T) defined in org.gradle.kotlin.dsl
public operator fun <T> Closure<TypeVariable(T)>.invoke(x: Any?): TypeVariable(T) defined in org.gradle.kotlin.dsl
public operator fun <T> Closure<TypeVariable(T)>.invoke(vararg xs: Any?): TypeVariable(T) defined in org.gradle.kotlin.dsl
public operator fun <V> Callable<TypeVariable(V)>.invoke(): TypeVariable(V) defined in org.gradle.kotlin.dsl
public operator fun <T, R> DeepRecursiveFunction<TypeVariable(T), TypeVariable(R)>.invoke(value: TypeVariable(T)): TypeVariable(R) defined in kotlin
...

最佳答案

实际上有一个issueAGP ,因为 gradle 崩溃了。
该问题已在 AGP 的下一版本中得到修复.目前我正在使用AGP 7.0.0带 Dagger 柄的版本2.37在安卓工作室北极狐没有问题。

// project level build.gradle
dependencies {
classpath "com.android.tools.build:gradle:7.0.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10"
classpath "com.google.dagger:hilt-android-gradle-plugin:2.37"
}
...

// app level build.gradle
implementation "com.google.dagger:hilt-android:2.37"
kapt "com.google.dagger:hilt-android-compiler:2.37"
...

关于android - 使用 android gradle 插件版本 7.0.0-alpha15 时无法使用 kotlin-gradle-dsl 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67588377/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com