MiraiForum

    • 注册
    • 登录
    • 搜索
    • 热门
    • 最新
    • 未解决
    • 标签
    • 群组
    • 友情链接

    未解决 gradle引入依赖错误

    开发交流
    2
    3
    406
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • Z
      zsd123ss 最后由 zsd123ss 编辑

      我项目的Github地址

      在执行fabric:build的时候出现了报错

      Could not determine the dependencies of task ':fabric:shadowJar'.
      > Could not resolve all dependencies for configuration ':fabric:shadow'.
         > Could not resolve net.mamoe:mirai-core:2.15.0-M1.
           Required by:
               project :fabric > project :common
            > Cannot choose between the following variants of net.mamoe:mirai-core:2.15.0-M1:
                - androidRuntimeElements-published
                - jvmRuntimeElements-published
              All of them match the consumer attributes:
                - Variant 'androidRuntimeElements-published' capability net.mamoe:mirai-core:2.15.0-M1:
                    - Unmatched attributes:
                        - Provides org.gradle.category 'library' but the consumer didn't ask for it
                        - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                        - Provides org.gradle.status 'release' but the consumer didn't ask for it
                        - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
                        - Provides org.jetbrains.kotlin.platform.type 'androidJvm' but the consumer didn't ask for it
                - Variant 'jvmRuntimeElements-published' capability net.mamoe:mirai-core:2.15.0-M1:
                    - Unmatched attributes:
                        - Provides org.gradle.category 'library' but the consumer didn't ask for it
                        - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                        - Provides org.gradle.status 'release' but the consumer didn't ask for it
                        - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
                        - Provides org.jetbrains.kotlin.platform.type 'jvm' but the consumer didn't ask for it
      

      几个关键文件

      • fabric/build.gradle#L38
      • common/build.gradle#L14 (fabric模块依赖的common模块)
      1 条回复 最后回复 回复 引用 0
      • Topic has been marked as a question  Z zsd123ss 
      • Karlatemp
        Karlatemp 最后由 编辑

        https://github.com/mamoe/mirai/issues/2402#issuecomment-1368473584

        将 org.jetbrains.kotlin.platform.type 定义为 jvm 即可

        kagg886 created this issue in mamoe/mirai

        closed Android环境下gradle依赖mirai报错 #2402

        Z 1 条回复 最后回复 回复 引用 0
        • Z
          zsd123ss @Karlatemp 最后由 zsd123ss 编辑

          @Karlatemp 在 gradle引入依赖错误 中说:

          https://github.com/mamoe/mirai/issues/2402#issuecomment-1368473584

          将 org.jetbrains.kotlin.platform.type 定义为 jvm 即可

          我不会改....又出现新的错误了

          Cannot have two attributes with the same name but different types. This container already has an attribute named 'org.jetbrains.kotlin.platform.type' of type 'org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType' and you are trying to store another one of type 'java.lang.String'
          

          我在common/build.gradle文件新增了几行

          configurations.all {
              attributes {
                  attribute(Attribute.of("org.jetbrains.kotlin.platform.type", String.class), "jvm")
              }
          }
          

          然后 common/build.gradle 就变成这样

          plugins {
              id 'org.jetbrains.kotlin.jvm' version '1.8.21'
          }
          
          dependencies {
              implementation "org.xerial:sqlite-jdbc:3.41.2.1"
              implementation 'com.alibaba.fastjson2:fastjson2:2.0.29'
              implementation 'org.yaml:snakeyaml:2.0'
          
              // chatgpt
              implementation 'com.github.plexpt:chatgpt:4.0.7'
              
              // mirai
              implementation 'net.mamoe:mirai-core:2.15.0-M1'
              
              implementation "net.kyori:adventure-api:4.13.1"
          }
          
          configurations.all {
              attributes {
                  attribute(Attribute.of("org.jetbrains.kotlin.platform.type", String.class), "jvm")
              }
          }
          

          我看一个人在其中一个pull说的可能有用?但不知道要怎么做 Link

          大佬能详细点吗
          或者说我修改的文件错了?

          1 条回复 最后回复 回复 引用 0
          • 1 / 1
          • First post
            Last post
          Powered by Mamoe Technologies & NodeBB | 友情链接 | 服务监控 | Contact