gpt4 book ai didi

android - 如何在 Android Studio 中修复库模块中的 "Cannot resolve symbol"?

转载 作者:行者123 更新时间:2023-12-02 11:19:52 25 4
gpt4 key购买 nike

这是我的项目设置:

  • 我在 Android Studio 项目中有 3 个模块(应用程序、功能和主题):
    Android Studio modules
  • 重要提示:仅限 :应用程序 & :主题模块有味道。 :功能 模块没有味道。
    flavorDimensions("product")

    productFlavors {
    paid { }
    demo { }
    free { }
    }
    这使得 Build Variants 看起来像这样:
    enter image description here
  • 这是依赖图:
    enter image description here

  • 所以:
  • :应用程序模块可以看到中的所有资源:主题模块,因为所有构建变体都匹配
  • 由于 :功能 模块没有味道,我已经声明了 :主题以这种方式依赖:implementation project(configuration: 'default', path: ':theme')👆👆👆 这使得项目构建成功✅ ✅ ✅
  • 但是, :功能 模块看不到 中定义的资源:主题模块。
  • 如果我删除 configuration: 'default'从依赖声明,我得到这个错误:
    ERROR: Unable to resolve dependency for ':feature@debug/compileClasspath': Could not resolve project :theme.
  • 这是 中的布局文件:功能 模块:
    enter image description here
  • product_name字符串在 中声明:主题与 flavor 名称匹配的不同目录中的模块

  • 问题是:
    如何制作 :功能 识别 中声明的资源的模块:主题无需在 中声明 flavor 的模块:功能 模块?

    最佳答案

    我试图重现您的错误并设法通过设置 missingDimensionStrategy 来修复它在您的 theme 的构建文件中模块:

    defaultConfig {
    ...
    missingDimensionStrategy 'product', 'demo', 'free', 'paid'
    }
    引用: https://developer.android.com/studio/build/dependencies#resolve_matching_errors

    关于android - 如何在 Android Studio 中修复库模块中的 "Cannot resolve symbol"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62673038/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com