cordova -无法解析com.android.tools.build:gradle:7.4.2

tquggr8v  于 2023-10-19  发布在  Android
关注(0)|答案(1)|浏览(226)

当使用cordova命令构建bundle时,我得到以下错误:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'project name'.
> Could not resolve all files for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:7.4.2.
     Required by:
         project :
      > No matching variant of com.android.tools.build:gradle:7.4.2 was found. The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.6' but:
          - Variant 'apiElements' capability com.android.tools.build:gradle:7.4.2 declares a library, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares an API of a component compatible with Java 11 and the consumer needed a runtime of a component compatible with Java 8
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '7.6')
          - Variant 'javadocElements' capability com.android.tools.build:gradle:7.4.2 declares a runtime of a component, and its dependencies declared externally:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about org.gradle.plugin.api-version (required '7.6')
          - Variant 'runtimeElements' capability com.android.tools.build:gradle:7.4.2 declares a runtime of a library, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 8
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '7.6')
          - Variant 'sourcesElements' capability com.android.tools.build:gradle:7.4.2 declares a runtime of a component, and its dependencies declared externally:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about org.gradle.plugin.api-version (required '7.6')

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.6/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 10s
Command failed with exit code 1: D:\project_name\platforms\android\gradlew -b D:\project_name\platforms\android\build.gradle :app:bundleRelease

Gradle版本:

Gradle 8.3
Kotlin:1.9.0
Groovy:3.0.17
Ant:Apache Ant(TM)版本1.10.13,编译于2023年1月4日
JVM:1.8.0_301(Oracle Corporation 25.301-b09)
操作系统:Windows 10 10.0

Java版本:

2023-07-18 Java版本“20.0.2”
Java(TM)SE嵌入式环境(build 20.0.2+9-78)
Java HotSpot(TM)64位服务器VM(build 20.0.2+9-78,混合模式,共享)

eh57zj3b

eh57zj3b1#

Cordova Android 12支持AGP_VERSION 7.4.2。他们还推出了Java版本。在您的情况下,Gradle JDK版本1.8 => 11或17应该可以解决此问题
https://cordova.apache.org/announcements/2023/05/22/cordova-android-12.0.0.html
https://github.com/apache/cordova-android/pull/1539

相关问题