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

相关推荐
00后程序员张3 小时前
IOScer 开发环境证书包括哪些,证书、描述文件与 App ID 的协同管理实践
android·ios·小程序·https·uni-app·iphone·webview
_大学牲3 小时前
Flutter 勇闯2D像素游戏之路(五):像元气骑士一样的设计随机地牢
flutter·游戏·游戏开发
aningxiaoxixi4 小时前
android AV 之 SimpleC2Component
android
TAEHENGV5 小时前
导入导出模块 Cordova 与 OpenHarmony 混合开发实战
android·javascript·数据库
君莫啸ོ5 小时前
Android基础-SwitchCompat自定义样式
android
5980354155 小时前
【java工具类】小数、整数转中文小写
android·java·开发语言
csj505 小时前
安卓基础之《(8)—中级控件(2)选择按钮》
android
液态不合群5 小时前
【面试题】MySQL 中的索引数量是否越多越好?为什么?
android·数据库·mysql
音浪豆豆_Rachel6 小时前
Flutter鸿蒙化之深入解析Pigeon非空字段设计:non_null_fields.dart全解
flutter·harmonyos
QING6186 小时前
Kotlin协程:Job.cancel() 和 Scope.cancel() 的区别详解!!!
android·kotlin·android jetpack