Gradle build failed Could not determine the dependencies of task ':launcher:buildReleasePreBundle'

I was trying to fix “Gradle build failed”, but nothing worked. Versions: android-ndk-r23b gradle-8.2 jdk-11.0.17 sdk from android studio unity 2023.1.0a21

Error:

stderr[
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

FAILURE: Build failed with an exception.

What went wrong:
Could not determine the dependencies of task ‘:launcher:buildReleasePreBundle’.
Could not create task ‘:launcher:stripReleaseDebugSymbols’.
Cannot use @TaskAction annotation on method IncrementalTask.taskAction$gradle_core() because interface org.gradle.api.tasks.incremental.IncrementalTaskInputs is not a valid parameter to an action method.

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 2s

]
stdout[

Configure project :launcher
WARNING:The option setting ‘android.bundle.enableUncompressedNativeLibs=false’ is deprecated.
The current default is ‘true’.
It will be removed in version 8.0 of the Android Gradle plugin.
You can add the following to your build.gradle instead:
android {
packagingOptions {
jniLibs {
useLegacyPackaging = true

    } }

}

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 Command-Line Interface in the Gradle documentation.

]
exit code: 1
I updated sdk, jdk, ndk and gradle from default that downloaded with Unity, but empty project can’t build for Android

i also encountered this error in unity 2022.3 lts version. When i downgrade to unity 2021 lts version, i can build and run into my quest 2. Upgrading gradle and downgrading resulting the same error, updating ndk too and using the recommended ndk version resulting gradle built error.

Hello,

Would you kindly please report this issue via the Bug Reporter tool?
https://unity.com/releases/editor/qa/bug-reporting
Please make sure to write the exact steps needed to be taken so that the reproduction would be visually seen. Also make sure to attach a reproduction project and any visual material so that when testing our CQA team can verify that they got the same results. If you can, please use this template:

How to reproduce:

  1. Open the attached project
  2. Do this
  3. Do that
  4. Select this
  5. Observe that

Expected result: Something is visible, something is printed or something happens
Actual result: The opposite of what I expect happens

Reproducible with: Editor version I am using (e.g: 2021.3.xf1)

Reproduced on: The OS I am on (e.g: Windows 11, macOS Ventura 13.1 (Intel/Silicon))