![](/img/trans.png)
[英]After adding Kapt plugin - A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
[英]Android - Gradle sync failed: org/jetbrains/kotlin/kapt/idea/KaptGradleModelorg/jetbrains/kotlin/kapt/idea/KaptGradleModel
昨天,無緣無故,我的 Android Studio 開始顯示以下消息:
Gradle sync failed: org/jetbrains/kotlin/kapt/idea/KaptGradleModelorg/jetbrains/kotlin/kapt/idea/KaptGradleModel
Consult IDE log for more details (Help | Show Log) (2 s 227 ms)
但我什至沒有使用 Kotlin:這些是我的 gradle 文件:
// 頂級構建文件,您可以在其中添加常見的配置選項
all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// Firebase import
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
// Stupid kotlin build-in plugin
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
apply plugin: 'com.android.application'
repositories {
jcenter()
}
android {
compileSdkVersion 28
testOptions {
unitTests {
includeAndroidResources = true
returnDefaultValues = true
}
}
defaultConfig {
applicationId "com.example.olegario.escamboapp"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
// Scroll view
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
// Firebase
implementation 'com.google.firebase:firebase-core:16.0.5'
// Firebase database
implementation 'com.google.firebase:firebase-database:16.0.6'
// Firebase storage
implementation 'com.google.firebase:firebase-storage:16.0.1'
// Firebase authentication
implementation 'com.google.firebase:firebase-auth:16.0.5'
// Mask
implementation 'com.vicmikhailau:MaskedEditText:2.0.4'
// test
testImplementation 'junit:junit:4.12'
testImplementation 'androidx.test:core:1.0.0'
testImplementation 'org.mockito:mockito-core:1.10.19'
testImplementation 'org.robolectric:robolectric:4.2'
androidTestImplementation 'org.mockito:mockito-android:+'
androidTestImplementation 'com.android.support:support-annotations:24.0.0'
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support.test:rules:0.5'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-contrib:3.0.2'
// Framework
implementation project(':capuccino')
}
apply plugin: 'com.google.gms.google-services'
為什么會這樣? 我昨天也更新了我的 Android Studio,到版本 3.4,但是這個錯誤在更新幾個小時后開始出現,所以我假設更新與錯誤無關。
升級您的 Kotlin 插件。
簡單的方法(推薦)。
Double shift -> Plugins -> Updates -> search Kotlin -> Update! -> Restart AS
手動方式(如果需要)。
1) 從此鏈接手動下載 Kotlin 插件。
2) Double shift -> Plugins -> (Settings) Icon -> Install from disk -> 選擇那個插件。
3) 重啟。
如果你不能更新它,你可以像這樣禁用它:Double shift -> Plugins -> installed -> search Kotlin -> right click -> Disable -> OK 再次打開這個對話框:Double shift -> Plugins ->安裝 -> 搜索 Kotlin -> 右鍵單擊 -> 啟用 -> 確定 -> 重啟 IDE 就完成了。
感謝“Salam Hiyali”,您的回答使我免於重新安裝 Android Studio ...
對給出的答案稍作修改
薩拉姆希亞里
Double shift -> 插件 -> 安裝 JetBrains 插件... --> 搜索 Kotlin -> 更新! -> 重啟AS
就我而言,我必須更新 gradle-wrapper.properties 文件中的distributionUrl
,最新版本可在官方 gradle 網站上獲得:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
幾天后,錯誤就從我的 IDE 中消失了。 我相信是上次更新中的某種錯誤。
升級到 Kotlin 1.4 插件后,我遇到了類似的問題。 我找到了一個解決方法,它應該適用於所有這些場景。
將idea
插件添加到build.gradle.kts
文件中。 然后關閉 IntelliJ 並手動運行gradle openIdea
這將在 idea 中打開項目,強制使用正確的配置。
不幸的是,它沒有修復同步按鈕的使用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.