在build.gradle
里面试图添加引用一个库:
kotlin
buildscript {
ext.kotlin_version = '1.7.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
implementation 'com.abc.def:ghi:114.514.1919810'
}
}
然后运行的时候报错:
A problem occurred evaluating root project 'android'.
> Could not find method implementation() for arguments [com.abc.def:ghi:114.514.1919810] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
可能原因:Flutter项目的android
目录下有两个build.gradle
文件,一个是android/build.gradle
,另一个是android/app/build.gradle
,在前者文件里面添加引用就会出这个错,解决办法是改在后者文件中另起一行添加:
kotlin
dependencies {
implementation 'com.abc.def:ghi:114.514.1919810'
}