NativeScript / NativeScript/android

Error: Could not resolve com.android.tools.build:gradle:8.3.2

Open
#1,829 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
563
Forks
144
Avg merge
10h 46m
Merged PRs (30d)
14

Description

Environment
My app.gradle:

// You can add your native dependencies here
dependencies {
//  implementation 'androidx.multidex:multidex:2.0.1'
}

android {
    compileSdkVersion 34
    buildToolsVersion "34"
    defaultConfig {
        minSdkVersion 23
        targetSdkVersion 34
        generatedDensities = []
    }

    aaptOptions {
        additionalParameters "--no-version-vectors"
    }
}

and before-plugins.gradle:

// this configurations is loaded before building plugins, as well as before building
// the app - this is where you can apply global settings and overrides

project.ext {
    // androidXAppCompat = "1.4.1"
    // androidXExifInterface = "1.3.3"
    // androidXFragment = "1.4.1"
    // androidXMaterial = "1.5.0"
    // androidXMultidex = "2.0.1"
    // androidXTransition = "1.4.1"
    // androidXViewPager = "1.0.0"

    useKotlin = true
    kotlinVersion = "1.6.0"
    androidBuildToolsVersion = "8.4.0"
}

Describtion
During building I get the following error and nothing changes even when I add androidBuildToolsVersion = "8.4.0" to before-plugings.gradle:

...
 @ ./src/main.ts 2:0-28
WARNING in ./src/app.android.scss
Module Warning (from ../../../../node_modules/@nativescript/webpack/node_modules/sass-loader/dist/cjs.js):
26 repetitive deprecation warnings omitted.
 @ ./src/main.ts 2:0-28
webpack 5.96.1 compiled with 16 warnings in 7855 ms
Webpack compilation complete.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'core'.
> Could not resolve all files for configuration ':classpath'.

> Could not resolve com.android.tools.build:gradle:8.3.2.
     Required by:
         project :
      > No matching variant of com.android.tools.build:gradle:8.3.2 was found. The consumer was configured to find a library for use during runtime, compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.4' but:
          - Variant 'apiElements' capability com.android.tools.build:gradle:8.3.2 declares a library, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component for use during compile-time, compatible with Java 11 and the consumer needed a component for use during runtime, compatible with Java 8
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.4')
          - Variant 'javadocElements' capability com.android.tools.build:gradle:8.3.2 declares
a component for use during runtime, 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 '8.4')
          - Variant 'runtimeElements' capability com.android.tools.build:gradle:8.3.2 declares a library for use during runtime, 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 '8.4')
          - Variant 'sourcesElements' capability com.android.tools.build:gradle:8.3.2 declares a component for use during runtime, 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 '8.4')
* 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.
BUILD FAILED in 855ms
Failed to build plugin @nativescript/core : 
Error: Command gradlew.bat failed with exit code 1

Both version seems the be hardcoded here: https://github.com/search?q=repo%3ANativeScript%2Fandroid%208.3.2&type=code and the androidBuildToolsVersion = "8.4.0" does not have any effect on the version. In the error message and under platforms/tempPlugin/core/build.gradle on line 40, it shows always the version 8.3.2: classpath 'com.android.tools.build:gradle:8.3.2'. It seems to come from package.json version_info. I tried Java 1.8, 11 and 23.

I would like to be able to override the gradle version number, so that I can resolve the error.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how the Android Gradle plugin version is selected from package.json version_info into platforms/tempPlugin/core/build.gradle around line 40; compare that path with before-plugins.gradle. Reproduce the Java 8 compatibility failure, then verify that the requested override is honored and the Android build resolves successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
build-system, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.