You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Flutter中集成DeepAR时遇到依赖解析错误求助

问题描述

在Flutter项目中集成DeepAR后构建失败,报错信息如下:

Could not determine the dependencies of task ':deepar_flutter:compileDebugAidl'.
> Could not resolve all task dependencies for configuration ':deepar_flutter:debugCompileClasspath'.
   > Could not find :deepar:. 
     Required by:
         project :deepar_flutter

已尝试以下操作但问题未解决:

  • 执行 flutter clean
  • 删除 pubspec.lock
  • 执行 flutter pub cache clean
  • 将deepar.aar复制到两个目录:
    • Flutter项目的android/app/libs/deepar.aar
    • %LOCALAPPDATA%\Pub\Cache\hosted\pub.dartlang.org\deepar_flutter-\android\libs\deepar.aar
解决办法

试试以下步骤:

  1. 配置Gradle本地仓库
    打开项目根目录下的android/build.gradle,在allprojects的repositories块中添加flatDir配置,让Gradle能识别本地libs目录的aar文件:

    allprojects {
        repositories {
            google()
            mavenCentral()
            flatDir {
                dirs 'libs', project(':deepar_flutter').file('libs')
            }
        }
    }
    

    同时打开deepar_flutter模块的android/build.gradle,确认依赖声明正确:

    dependencies {
        implementation(name: 'deepar', ext: 'aar')
    }
    
  2. 校验aar文件的正确性
    检查deepar.aar文件名是否完全正确(无拼写、大小写错误),且确实放置在deepar_flutter模块的android/libs目录下,不要只放在app模块的libs里。

  3. 重新构建项目
    先清理Gradle缓存并同步:

    cd android
    ./gradlew clean
    ./gradlew sync
    

    回到项目根目录执行:

    flutter run
    
  4. 使用本地依赖替代缓存包
    不要修改Pub缓存中的文件,建议在pubspec.yaml中引入本地的deepar_flutter模块:

    dependencies:
      deepar_flutter:
        path: ./relative/path/to/deepar_flutter
    

    这样可以直接修改本地模块的配置,更易维护。

内容的提问来源于stack exchange,提问作者Om Shivam

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.11 09:25:35