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

相关推荐
mygljx8 小时前
【MySQL 的 ONLY_FULL_GROUP_BY 模式】
android·数据库·mysql
冬奇Lab10 小时前
AudioTrack音频播放流程深度解析
android·音视频开发·源码阅读
国医中兴11 小时前
Flutter 三方库 stack_blur 鸿蒙适配指南 - 实现工业级高性能模糊滤镜、在 OpenHarmony 上打造极致视觉质感实战
flutter·华为·harmonyos
青莲84313 小时前
查找算法详解
android·前端
青莲84313 小时前
排序算法详解
android·前端
Justin在掘金13 小时前
Flutter Provider 状态管理深度指南
flutter
zd20057213 小时前
用摩斯密码「听」时间:一款安卓报时应用的诞生
android
不会写代码的猴子14 小时前
Android17版本更新预览
android·android studio
用户416596736935515 小时前
记一次深坑:RecyclerView + FlexboxLayoutManager 导致 canScrollVertically 误判的剖析与修复
android