apply plugin: 'kotlin-android-extensions'.当我在android studio预览版中添加这个扩展时,给我这个错误" 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'
}发布于 2017-09-23 06:15:26
您发布的build.gradle代码片段看起来像应用程序模块中的配置。项目根目录中的build.gradle是什么样子的?要添加kotlin插件依赖项,应该如下所示:
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插件。
发布于 2017-11-21 22:57:14
要使用该插件,必须将其添加到根build.gradle文件中
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"
}
}发布于 2020-12-15 14:51:54
在Android Studio中,我们可以在下面的ways:_中修复它
在App Level Graddle中使用插件领域特定语言(DSL)
plugins {
id "org.jetbrains.kotlin.android.extensions" version "1.4.21"
}这就是解决它的所有方法。
但是,如果您使用的是遗留插件应用程序,那么在应用程序级别Gradle中添加以下内容
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"希望这会对你有所帮助!
https://stackoverflow.com/questions/46101908
复制相似问题