MiraiForum

    • Register
    • Login
    • Search
    • Popular
    • Recent
    • Unsolved
    • Tags
    • Groups
    • 友情链接

    Unsolved gradle引入依赖错误

    开发交流
    2
    3
    422
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Z
      zsd123ss last edited by 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 Reply Last reply Reply Quote 0
      • Topic has been marked as a question  Z zsd123ss 
      • Karlatemp
        Karlatemp last edited by

        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 Reply Last reply Reply Quote 0
        • Z
          zsd123ss @Karlatemp last edited by 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 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Powered by Mamoe Technologies & NodeBB | 友情链接 | 服务监控 | Contact