错误:(1, 0) 未找到 ID 为“kotlin-android-extensions"的插件 [英] Error:(1, 0) Plugin with id 'kotlin-android-extensions' not found
问题描述
apply plugin: 'kotlin-android-extensions'.
当我在 android studio preview 中添加这个扩展时,给我这个错误错误:(1, 0) 未找到 ID 为 'kotlin-android-extensions' 的插件.".
When i add this extensions in android studio preview, give me this error "Error:(1, 0) Plugin with id 'kotlin-android-extensions' not found.".
我的构建gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.example.mohamed_elbaz.myapplication"
minSdkVersion 15
targetSdkVersion 26
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:26.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
推荐答案
您发布的 build.gradle 片段看起来像您的应用模块中的配置.您项目根目录中的 build.gradle 是什么样的?要添加 kotlin 插件依赖项,它应该如下所示:
The build.gradle snippet you posted looks like the config inside your app module. What does the build.gradle in your project's root directory look like? To add the kotlin plugin dependencies it should look something like this:
buildscript {
ext.kotlin_version = '1.1.50'
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta6'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
重要的部分是添加 kotlin 插件的 classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
行.
The important part being the line classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
which adds the kotlin plugins.
这篇关于错误:(1, 0) 未找到 ID 为“kotlin-android-extensions"的插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!