apache / cordova-android

Apache Cordova Android
https://cordova.apache.org/
Apache License 2.0
3.65k stars 1.54k forks source link

No matching variant of com.android.tools.build:gradle:7.4.2 was found #1683

Closed Mehuge closed 10 months ago

Mehuge commented 10 months ago

Bug Report

Problem

Building a freshly created basic HelloWorld project, the build is failing with

No matching variant of com.android.tools.build:gradle:7.4.2 was found

What is expected to happen?

The build to work.

What does actually happen?

The build fails with No matching variant of com.android.tools.build:gradle:7.4.2 was found

Information

Command or Code

#!/bin/bash
npm i cordova@12.0.0 cordova-android@12.0.1
PATH=$PWD/node_modules/.bin:$PATH; export PATH

cordova -v
cordova create HelloWorld com.hello.world HelloWorld
cd HelloWorld
cordova platform add android
cordova requirements
cordova build android

Environment, Platform, Device

Java JDK: installed 1.8.0 Android SDK: installed true Android target: not installed Command failed with ENOENT: avdmanager list target spawn avdmanager ENOENT Gradle: installed /usr/local/Cellar/gradle/8.4/bin/gradle Some of requirements check failed Checking Java JDK and Android SDK versions ANDROID_HOME=undefined (recommended setting) ANDROID_SDK_ROOT=/Users/adf/Library/android/sdk (DEPRECATED) Using Android SDK: /Users/adf/Library/Android/sdk

Version information

Cordova 12.0.0 Cordova Android 12.0.1 Cordova Lib 12.0.1 macOS Ventura 13.4 (22F66) Android Studio Artic Fox: 2020.3.1 patch 1

Android SDK details

image image image

Build Output / Error Messages

Build Output ``` npm WARN deprecated stringify-package@1.0.1: This module is not used anymore, and has been replaced by @npmcli/package-json npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs npm WARN deprecated har-validator@5.1.5: this library is no longer supported npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 added 555 packages, and audited 556 packages in 3s 63 packages are looking for funding run `npm fund` for details 4 moderate severity vulnerabilities To address all issues (including breaking changes), run: npm audit fix --force Run `npm audit` for details. 12.0.0 (cordova-lib@12.0.1) Creating a new cordova project. Using cordova-fetch for cordova-android Adding android project... Creating Cordova project for the Android platform: Path: platforms/android Package: com.hello.world Name: HelloWorld Activity: MainActivity Android Target SDK: android-33 Android Compile SDK: 33 Subproject Path: CordovaLib Subproject Path: app Android project created with cordova-android@12.0.1 Requirements check results for android: Java JDK: installed 1.8.0 Android SDK: installed true Android target: not installed Command failed with ENOENT: avdmanager list target spawn avdmanager ENOENT Gradle: installed /usr/local/Cellar/gradle/8.4/bin/gradle Some of requirements check failed Checking Java JDK and Android SDK versions ANDROID_HOME=undefined (recommended setting) ANDROID_SDK_ROOT=/Users/xxx/Library/android/sdk (DEPRECATED) Using Android SDK: /Users/xxx/Library/Android/sdk Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0. You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins. For more on this, please refer to https://docs.gradle.org/8.4/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation. BUILD SUCCESSFUL in 884ms 1 actionable task: 1 executed Subproject Path: CordovaLib Subproject Path: app FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring root project 'HelloWorld'. > 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 873ms Command failed with exit code 1: /Users/xxx/Sites/RMC2/cordova2/HelloWorld/platforms/android/gradlew -b /Users/xxx/Sites/RMC2/cordova2/HelloWorld/platforms/android/build.gradle cdvBuildDebug

Checklist

breautek commented 10 months ago

Duplicate of https://github.com/apache/cordova-android/issues/1682