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

相关推荐
小成很成14 小时前
mysql 8.0.21 升级 mysql 8.0.45(经过生产环境验证)
android·mysql·adb
虎王物联19 小时前
PHP实现MQTT消息处理:物联网设备数据接收与指令下发
android·物联网·php
我命由我1234519 小时前
Android 开发 - 获取当前设备屏幕的旋转角度
android·java·java-ee·android studio·android jetpack·android-studio·android runtime
程序员-Benothing21 小时前
MySQL 索引下推是什么?——深入理解 ICP 原理与实践
android·数据库·mysql
怀化纱厂球迷21 小时前
百度地图--android接入百度地图导航
android
AFinalStone1 天前
Android 7系统无障碍服务(四)AccessibilityEvent 的产生与投递
android·无障碍服务
智购科技无人售货机工厂1 天前
2026自动售货机热敏打印模块集成:从串口驱动到小票自动裁切的工程实践~YH
android·stm32·单片机·嵌入式硬件·系统架构
A13345551 天前
苹果安卓手机播放器推荐:2026无广告4K怎么选
android·智能手机
hunterandroid1 天前
ContentProvider 跨进程数据共享实战
android·前端