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

相关推荐
月夜风雨磊3 小时前
Android NDK从r10c版本到r29版本的下载链接
android·gitee·android ndk
louisgeek4 小时前
Android MIUI 开启 Google Play 服务
android
独行soc4 小时前
2025年大模型安全岗的面试汇总(题目+回答)
android·人工智能·安全·面试·职场和发展·渗透测试
前行的小黑炭5 小时前
Android App:每次想写新项目锻炼一下,但苦于没有UI,那么这篇文章适合你~(适合基础小白锻炼)
android·kotlin
雨白7 小时前
压缩、序列化与哈希
android
安卓开发者8 小时前
RxJava 核心概念解析:构建响应式Android应用的基石
android·echarts·rxjava
叽哥8 小时前
flutter学习第 18 节:设备功能调用
android·flutter·ios
Monkey-旭9 小时前
Android ADB 常用指令全解析
android·adb
来来走走10 小时前
Flutter 顶部导航标签组件Tab + TabBar + TabController
android·flutter
丐中丐99910 小时前
Android NFC框架的NfcService与hal层代码概览
android