Flutter导入安卓第三方库报错:Flutter Could not find method implementation() 的可能原因及解决办法

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'
}

参考来源:https://ourcodeworld.com/articles/read/1590/how-to-solve-android-error-could-not-find-method-implementation-for-arguments-on-object-of-type-orggradleapiinternalartifactsdsldependenciesdefaultdependencyhandler

相关推荐
HeDongDong-7 分钟前
Kotlin 协程(Coroutines)详解
android·开发语言·kotlin
allk5528 分钟前
Android APK 极限瘦身:从构建链优化到架构演进
android·架构
啊西:30 分钟前
SuperMap iMobile for Android中模型按照指定路径运动
android
码农101号36 分钟前
Ansible - Role介绍 和 使用playbook部署wordPress
android·ansible
a_eastern38 分钟前
linux electron-forge离线打包关键配置
android·linux·electron
进击的前栈1 小时前
Flutter跨平台聊天组件testchat鸿蒙化使用指南
flutter·华为·harmonyos
城东米粉儿1 小时前
Dynamic Feature Modules 笔记
android
花开彼岸天~1 小时前
Flutter跨平台图片加载鸿蒙化性能调优指南
flutter·华为·harmonyos
无言Echo1 小时前
Android 高斯模糊(1) 窗口模糊及java侧基本流程简述
android
无言Echo1 小时前
Android 高斯模糊(2)BackgroundBlurDrawable使用及相关Bug
android