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

相关推荐
奋斗的小青年!!5 分钟前
Flutter跨平台开发适配OpenHarmony:下拉刷新组件的实战优化与深度解析
flutter·harmonyos·鸿蒙
sugarzhangnotes6 分钟前
MySQL 8.0升级中的字符集陷阱与解决方案
android·数据库·mysql
3***g2059 分钟前
C盘清理技巧分享了解C盘空间占用情况
android
摘星编程24 分钟前
Flutter for OpenHarmony 实战:CustomScrollView 自定义滚动视图详解
android·javascript·flutter
摘星编程1 小时前
Flutter for OpenHarmony 实战:GridView.builder 构建器网格详解
flutter
lynn8570_blog1 小时前
关于compose的remember
android·kotlin
绝命三郎1 小时前
Flutter坑坑
flutter
毕设源码-邱学长1 小时前
【开题答辩全过程】以 基于安卓的外卖点餐APP的设计与实现为例,包含答辩的问题和答案
android
csj502 小时前
安卓基础之《(16)—内容提供者(2)使用内容组件获取通讯信息》
android