[SOLVED] Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0

Question

This Content is from Stack Overflow. Question asked by Festus Akushie

I have been working on this project and everything seem perfect until about a week ago, I tried to launch the project on an emulator and ran into the error below.

$ yarn react-native run-android
yarn run v1.22.15
$ C:UsersChifesDesktopappsRoGoodsnode_modules.binreact-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1519 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
info Installing the app...

> Task :react-native-gradle-plugin:compileKotlin
'compileJava' task (current target is 1.8) and 'compileKotlin' task (current target is 11) jvm target compatibility should be set to the same Java version.
w: C:UsersChifesDesktopappsRoGoodsnode_modulesreact-native-gradle-pluginsrcmainkotlincomfacebookreactReactExtension.kt: (10, 37): 'BaseVariant' is deprecated. Deprecated in Java
w: C:UsersChifesDesktopappsRoGoodsnode_modulesreact-native-gradle-pluginsrcmainkotlincomfacebookreactReactExtension.kt: (119, 30): 'BaseVariant' is deprecated. Deprecated in Java
w: C:UsersChifesDesktopappsRoGoodsnode_modulesreact-native-gradle-pluginsrcmainkotlincomfacebookreactReactExtension.kt: (135, 26): 'BaseVariant' is deprecated. Deprecated in Java
w: C:UsersChifesDesktopappsRoGoodsnode_modulesreact-native-gradle-pluginsrcmainkotlincomfacebookreactReactExtension.kt: (155, 32): 'BaseVariant' is deprecated. Deprecated in Java
w: C:UsersChifesDesktopappsRoGoodsnode_modulesreact-native-gradle-pluginsrcmainkotlincomfacebookreactReactExtension.kt: (161, 31): 'BaseVariant' is deprecated. Deprecated in Java
w: C:UsersChifesDesktopappsRoGoodsnode_modulesreact-native-gradle-pluginsrcmainkotlincomfacebookreactReactExtension.kt: (169, 36): 'BaseVariant' is deprecated. Deprecated in Java
w: C:UsersChifesDesktopappsRoGoodsnode_modulesreact-native-gradle-pluginsrcmainkotlincomfacebookreactReactPlugin.kt: (99, 48):
'reactRoot: DirectoryProperty' is deprecated. reactRoot was confusing and has been replace with rootto point to your root project and reactNativeDir to point to the folder of the react-native NPM package
w: C:UsersChifesDesktopappsRoGoodsnode_modulesreact-native-gradle-pluginsrcmainkotlincomfacebookreactTaskConfiguration.kt: (10, 37): 'ApplicationVariant' is deprecated. Deprecated in Java
w: C:UsersChifesDesktopappsRoGoodsnode_modulesreact-native-gradle-pluginsrcmainkotlincomfacebookreactTaskConfiguration.kt: (11, 37): 'BaseVariant' is deprecated. Deprecated in Java
w: C:UsersChifesDesktopappsRoGoodsnode_modulesreact-native-gradle-pluginsrcmainkotlincomfacebookreactTaskConfiguration.kt: (12, 37): 'LibraryVariant' is deprecated. Deprecated in Java
w: C:UsersChifesDesktopappsRoGoodsnode_modulesreact-native-gradle-pluginsrcmainkotlincomfacebookreactTaskConfiguration.kt: (28, 51): 'BaseVariant' is deprecated. Deprecated in Java
w: C:UsersChifesDesktopappsRoGoodsnode_modulesreact-native-gradle-pluginsrcmainkotlincomfacebookreactTaskConfiguration.kt: (131, 12): 'ApplicationVariant' is deprecated. Deprecated in Java
w: C:UsersChifesDesktopappsRoGoodsnode_modulesreact-native-gradle-pluginsrcmainkotlincomfacebookreactTaskConfiguration.kt: (132, 12): 'LibraryVariant' is deprecated. Deprecated in Java
w: C:UsersChifesDesktopappsRoGoodsnode_modulesreact-native-gradle-pluginsrcmainkotlincomfacebookreactTaskConfiguration.kt: (250, 14): 'BaseVariant' is deprecated. Deprecated in Java

> Task :react-native-gradle-plugin:compileJava

> Configure project :app
Unable to detect AGP versions for included builds. All projects in the build should use the same AGP version. Class name for the included build object: org.gradle.composite.internal.DefaultIncludedBuild$IncludedBuildImpl_Decorated.

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.3.3/userguide/command_line_interface.html#sec:command_line_warnings
6 actionable tasks: 6 executed
Note: C:UsersChifesDesktopappsRoGoodsnode_modulesreact-native-gradle-pluginsrcmainjavacomfacebookreactcodegengeneratorSchemaJsonParser.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

FAILURE: Build failed with an exception.

* Where:
Build file 'C:UsersChifesDesktopappsRoGoodsnode_modulesreact-native-reanimatedandroidbuild.gradle' line: 64

* What went wrong:
A problem occurred configuring project ':react-native-reanimated'.
> Configuration with name 'compile' not found.

* 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 5m 4s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
Note: C:UsersChifesDesktopappsRoGoodsnode_modulesreact-native-gradle-pluginsrcmainjavacomfacebookreactcodegengeneratorSchemaJsonParser.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

FAILURE: Build failed with an exception.

* Where:
Build file 'C:UsersChifesDesktopappsRoGoodsnode_modulesreact-native-reanimatedandroidbuild.gradle' line: 64

* What went wrong:
A problem occurred configuring project ':react-native-reanimated'.
> Configuration with name 'compile' not found.

* 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 5m 4s

    at makeError (C:UsersChifesDesktopappsRoGoodsnode_modulesexecaindex.js:174:9)
    at C:UsersChifesDesktopappsRoGoodsnode_modulesexecaindex.js:278:16
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async runOnAllDevices (C:UsersChifesDesktopappsRoGoodsnode_modules@react-native-communitycli-platform-androidbuildcommandsrunAndroidrunOnAllDevices.js:109:5)
    at async Command.handleAction (C:UsersChifesDesktopappsRoGoodsnode_modules@react-native-communityclibuildindex.js:192:9)
info Run CLI with --verbose flag for more details.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Here is my package.json content

{
  "name": "RoGoods",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@react-native-community/geolocation": "^2.0.2",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-native-community/netinfo": "^5.9.10",
    "@react-navigation/drawer": "^5.12.3",
    "@react-navigation/native": "^5.9.2",
    "@react-navigation/stack": "^5.14.2",
    "aws-amplify-react-native": "*",
    "react": "17.0.2",
    "react-native": "0.68.0",
    "react-native-gesture-handler": "^1.9.0",
    "react-native-google-places-autocomplete": "^2.4.1",
    "react-native-maps": "^0.27.1",
    "react-native-maps-directions": "^1.8.0",
    "react-native-reanimated": "^1.13.2",
    "react-native-safe-area-context": "^3.1.9",
    "react-native-screens": "^2.17.1",
    "react-native-vector-icons": "^9.1.0",
    "styled-components": "^5.3.5"
  },
  "devDependencies": {
    "@babel/core": "7.17.8",
    "@babel/runtime": "7.17.8",
    "@react-native-community/eslint-config": "2.0.0",
    "babel-jest": "26.6.3",
    "eslint": "7.32.0",
    "jest": "26.6.3",
    "metro-react-native-babel-preset": "0.67.0",
    "react-test-renderer": "17.0.2"
  },
  "jest": {
    "preset": "react-native"
  }
}

Over the past week, I have tried everything to fix this error but nothing seem to work. I have uninstalled most of the packages, but can’t seem to figure what the problem is. Any help will be richly appreciated.

Solution

Run the Gradle build with a command line argument --warning-mode=all to see what exactly the deprecated features are.

It will give you a detailed description of found issues with links to the Gradle docs for instructions how to fix your build.

Adding --stacktrace to that, you will also be able to pinpoint where the warning comes from, if it’s triggered by outdated code in one of the plugins and not your build script.

Answered by hotkey, Content is distributed under the terms of CC BY-SA 4.0.

people found this article helpful. What about you?