我最近安装了android studio,我没有遇到任何问题,突然出现这个错误,我不知道这是什么 这个问题与build.gradle.kts(模块应用程序)有关 起初,我收到另一个错误,标题为“在以下任何来源中均未找到插件 [id: 'com.android.application']:”
这是整个 build.gradle.kts(模块应用程序)代码:
plugins {
id("com.android.application") version "8.2.0" apply false
id("com.android.library") version "8.2.0" apply false
id("org.jetbrains.kotlin.android") version "1.9.20" apply false
}
android {
namespace = "com.example.myapplication"
compileSdk = 34
defaultConfig {
applicationId = "com.example.myapplication"
minSdk = 24
targetSdk = 34
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
dependencies {
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.9.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
}
然后我在插件中添加了这3个代码:
id("com.android.application") version "8.2.0" apply false
id("com.android.library") version "8.2.0" apply false
id("org.jetbrains.kotlin.android") version "1.9.20" apply false
然后我收到了这个错误:“e:file:///C:/Users/EXO/AndroidStudioProjects/MyApplication/app/build.gradle.kts:8:1:未解析的参考:android”与android方法相关8
2 件事:
apply false
。android.library
和 android.application
。