首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误:找不到id为'kotlin-android-extensions‘的(1,0)插件

错误:找不到id为'kotlin-android-extensions‘的(1,0)插件
EN

Stack Overflow用户
提问于 2017-09-08 01:13:41
回答 4查看 72.5K关注 0票数 53
代码语言:javascript
复制
apply plugin: 'kotlin-android-extensions'.

当我在android studio预览版中添加这个扩展时,给我这个错误" error :(1,0) Plugin with id 'kotlin-android- extensions‘not found.“。

我的构建gradle

代码语言:javascript
复制
   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'
}
EN

回答 4

Stack Overflow用户

发布于 2017-09-23 06:15:26

您发布的build.gradle代码片段看起来像应用程序模块中的配置。项目根目录中的build.gradle是什么样子的?要添加kotlin插件依赖项,应该如下所示:

代码语言:javascript
复制
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
}

重要的部分是classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"行,它添加了kotlin插件。

票数 77
EN

Stack Overflow用户

发布于 2017-11-21 22:57:14

要使用该插件,必须将其添加到根build.gradle文件中

代码语言:javascript
复制
buildscript {
ext.kotlin_version = '1.1.60'
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com'
        }
    }

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}
票数 58
EN

Stack Overflow用户

发布于 2020-12-15 14:51:54

在Android Studio中,我们可以在下面的ways:_中修复它

App Level Graddle中使用插件领域特定语言(DSL)

代码语言:javascript
复制
plugins {
    id "org.jetbrains.kotlin.android.extensions" version "1.4.21"
}

这就是解决它的所有方法。

但是,如果您使用的是遗留插件应用程序,那么在应用程序级别Gradle中添加以下内容

代码语言:javascript
复制
buildscript {
  repositories {
    maven {
      url "https://plugins.gradle.org/m2/"
    }
  }
  dependencies {
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.21"
  }
}

apply plugin: "org.jetbrains.kotlin.android.extensions"

希望这会对你有所帮助!

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46101908

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档