only id(String) method calls allowed in plugins {} script block

来源:2-3 使用Kotlin编写app-build.gradle

LHgreenbird

2021-11-26

背景
在2-2节里编译之后提示
Plugin with id ‘com.android.application’ not found.的问题没有解决,自己也不懂,看到老师在
Plugin id: ‘com.android.application’ was not found
的回答就无视它了。
问题描述
AS:3.5.2
gradle 5.4.1
kotlin:1.3.50
app/build.gralde.kts
按照视频编写的插件引入代码如下

//引用插件
plugins {
    id ("com.android.application")
    kotlin ("android")
    kotlin ("android.extensions")
}

其中编写的依赖代码如下

dependencies {
    implementation(fileTree(mapOf("dir" ,"libs", "include" , listOf("*.jar"))))
//    1.3.50 $kotlin_version
    implementation ("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.50")
    implementation ("androidx.appcompat:appcompat:1.0.2")
    implementation ("androidx.core:core-ktx:1.0.2")
}

sync(大象图标)之后提示:

10: only id(String) method calls allowed in plugins {} script block
plugins_block for information on the plugins {} block
@ line 10, column 5.
       kotlin("android")
       ^
       11: only id(String) method calls allowed in plugins {} script block
       plugins_block for information on the plugins {} block

 @ line 11, column 5.
       kotlin("android.extensions")
       ^

之后签名也没创建好。

写回答

1回答

刘某人

2021-11-29

改回旧版gradle才这样,新版的对插件引入做了一些修改的

0
0

Kotlin+组件化 打造AI语音助手App 解锁交互技能包

基于百度AI打造一款集WakeUp,TTS,ASR为一体的服务类助手App

219 学习 · 49 问题

查看课程