我正在我的 Flutter 应用程序中使用我自己的插件
payment_module
。对于这个插件,我需要使用 .aar 格式的外部 SDK。
当我同步 gradle 时,它成功同步,但在运行 flutter 应用程序时出现以下错误。
FAILURE: Build failed with an exception.
* Where:
Build file '%Your_Path%/payment_module/android/build.gradle' line: 64
* What went wrong:
A problem occurred evaluating project ':payment_module'.
> Project with path ':boltsdk' could not be found in project ':payment_module'.
在新的 android Studio 版本中,我们无法直接导入 .aar 作为模块,我已遵循 https://stackoverflow.com/a/70074787/22637043.
的建议。payment_module/android/boltsdk
boltsdk gradle 文件
configurations.maybeCreate("default")
artifacts.add("default", file('boltsdk-release-3.0.86.aar'))
我的build.gradle
dependencies {
..
..
api project(path: ':boltsdk')
/// I also tried implementation project(path: ':boltsdk')
/// and also tried implementation files('boltsdk/boltsdk-release-3.0.86.aar')
/// for this I get this error Error building Android library: Direct local .aar file dependencies are not supported
..
}
settings.gradle 文件
rootProject.name = 'payment_module'
include ':boltsdk'
为此,我已经尝试了 在根项目“myproject”中找不到路径为“:mypath”的项目
的多种解决方案在此文件中添加以下内容 payment_module/android/build.gradle
注意它不在示例目录中
rootProject.allprojects {
repositories {
google()
mavenCentral()
flatDir {
dirs project(':payment_module').file("libs")
}
}
}