React-native: Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0

Created on 2 Sep 2020  路  18Comments  路  Source: facebook/react-native

Hi

i dont know whats wrong but i am getting this error continuously. Even i tried all with the fresh version also.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warnings
27 actionable tasks: 27 executed
Note: D:\KikleeApp\master2\kikleeapp\android\app\src\debug\java\com\kikleeapp\ReactNativeFlipper.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Unable to install D:\KikleeApp\master2\kikleeapp\android\app\build\outputs\apk\debug\app-debug.apk
com.android.ddmlib.InstallException: INSTALL_FAILED_USER_RESTRICTED
        at com.android.ddmlib.Device.installRemotePackage(Device.java:1133)
        at com.android.ddmlib.Device.installPackage(Device.java:963)
        at com.android.ddmlib.Device.installPackage(Device.java:939)
        at com.android.ddmlib.Device.installPackage(Device.java:928)
        at com.android.builder.testing.ConnectedDevice.installPackage(ConnectedDevice.java:126)
        at com.android.build.gradle.internal.tasks.InstallVariantTask.install(InstallVariantTask.java:175)
        at com.android.build.gradle.internal.tasks.InstallVariantTask.doTaskAction(InstallVariantTask.java:106)
        at com.android.build.gradle.internal.tasks.NonIncrementalTask$taskAction$$inlined$recordTaskAction$1.invoke(AndroidVariantTask.kt:51)
        at com.android.build.gradle.internal.tasks.NonIncrementalTask$taskAction$$inlined$recordTaskAction$1.invoke(AndroidVariantTask.kt:31)
        at com.android.build.gradle.internal.tasks.Blocks.recordSpan(Blocks.java:91)
        at com.android.build.gradle.internal.tasks.NonIncrementalTask.taskAction(NonIncrementalTask.kt:34)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:104)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:49)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:42)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:28)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:727)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:694)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.run(ExecuteActionsTaskExecuter.java:568)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:402)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:394)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:92)
        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:553)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:536)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.access$300(ExecuteActionsTaskExecuter.java:109)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.executeWithPreviousOutputFiles(ExecuteActionsTaskExecuter.java:276)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.execute(ExecuteActionsTaskExecuter.java:265)
        at org.gradle.internal.execution.steps.ExecuteStep.lambda$execute$1(ExecuteStep.java:33)
        at java.util.Optional.orElseGet(Optional.java:267)
        at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:33)
        at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:26)
        at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:67)
        at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:36)
        at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:49)
        at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:34)
        at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:43)
        at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:73)
        at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:54)
        at org.gradle.internal.execution.steps.CatchExceptionStep.execute(CatchExceptionStep.java:34)
        at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:44)
        at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:54)
        at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:38)
        at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:49)
        at org.gradle.internal.execution.steps.CacheStep.executeWithoutCache(CacheStep.java:153)
        at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:67)
        at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:41)
        at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:44)
        at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:33)
        at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:38)
        at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:24)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:92)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$0(SkipUpToDateStep.java:85)
        at java.util.Optional.map(Optional.java:215)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:55)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:39)
        at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:76)
        at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:37)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:36)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:26)
        at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:94)
        at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:49)
        at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:79)
        at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:53)
        at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:74)
        at org.gradle.internal.execution.steps.SkipEmptyWorkStep.lambda$execute$2(SkipEmptyWorkStep.java:78)
        at java.util.Optional.orElseGet(Optional.java:267)
        at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:78)
        at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:34)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsStartedStep.execute(MarkSnapshottingInputsStartedStep.java:39)
        at org.gradle.internal.execution.steps.LoadExecutionStateStep.execute(LoadExecutionStateStep.java:40)
        at org.gradle.internal.execution.steps.LoadExecutionStateStep.execute(LoadExecutionStateStep.java:28)
        at org.gradle.internal.execution.impl.DefaultWorkExecutor.execute(DefaultWorkExecutor.java:33)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:192)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:184)
        at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:114)
        at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:62)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
        at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:41)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:372)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:359)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:352)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:338)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:127)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:191)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:182)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:124)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
        at java.lang.Thread.run(Thread.java:748)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: INSTALL_FAILED_USER_RESTRICTED

* 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 2m 12s

i tried all my procedures like for instance

  1. Fresh installation of android studio
  2. downgrade the jdk version
  3. removing buil, grade folder these things are different. Because i tried this all with a new fresh version also where it giving me the same error.

info Fetching system and libraries information...
System:
OS: Windows 10 10.0.18363
CPU: (4) x64 Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz
Memory: 1.43 GB / 5.59 GB
Binaries:
Node: 13.9.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.14.4 - C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK: Not Found
Windows SDK: Not Found
IDEs:
Android Studio: Version 4.0.0.0 AI-193.6911.18.40.6626763
Visual Studio: Not Found
Languages:
Java: 1.8.0_161
Python: 2.7.17
npmPackages:
@react-native-community/cli: Not Found
react: 16.13.1 => 16.13.1
react-native: 0.63.2 => 0.63.2
npmGlobalPackages:
react-native: Not Found

DX Flipper Attention

Most helpful comment

Hello everyone,

Just sharing my experience as I could solve it on my side, so if it can help...

Context:
THIS IS A NEW ERROR. I had not touched RN for a while and I just wanted to create a new project. I got the same error only after running react-native init and react-native run-android.

Solution:

  • I followed this previous answer on a similar issue
  • This brought to the Gradle versions correspondances
  • I updated the classpath("com.android.tools.build:gradle:X.X.X") in android/build.gradle (it was version 3.5.3, I now use version 4.1.0)
  • The next triggered error required to update gradle from verion 6.2 to 6.5. So, I updated distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip in android/gradle/wrapper/gradle-wrapper.properties

If you still have other errors that you did not have in the past, please notice that you may need to:

  • touch /home/$USER/.android/repositories.cfg
  • sudo chown $USER:$USER $ANDROID_HOME -R
  • Update your SDK (using /opt/android/tools/android update sdk --no-ui --all --filter "android-XX" using an adapted version, currently "android-29" works well)
  • Accept licences you had not accepted before (using /opt/android/tools/bin/sdkmanager --licenses)

I hope it could help as I know it is not pleasant to just try to start a project needing to fix things.

All 18 comments

:warning: Missing Environment Information
:information_source: Your issue may be missing information about your development environment. You can obtain the missing information by running react-native info in a console.

Recent react native version having huge issues with android gradle. still i am finding its solution

Hi @wontone18, I looks like the Flipper version is causing issues.

We have an open PR for it here: https://github.com/facebook/react-native/pull/29787

Could you apply the diff to your project and see if it helps?

I will check the above point. But in my thinking its some where else is the issue. It making all the package components invalid and deprecated. Some of those packages we are regularly using

  1. asyncstorage
  2. webview

etc. gradle is somewhere making all these issues.

I can see several users are facing this issue but nobody getting a better result.

Hi @wontone18, I looks like the Flipper version is causing issues.

We have an open PR for it here: #29787

Could you apply the diff to your project and see if it helps?

Same issue by using your flipper github version.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warnings
24 actionable tasks: 24 executed
Note: D:\sourcetest\reactnative\flipper\android\app\src\debug\java\com\mrltestnative\ReactNativeFlipper.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Unable to install D:\sourcetest\reactnative\flipper\android\app\build\outputs\apk\debug\app-debug.apk

Hi at last issue is resolve. There are few things to be check.

  1. check the project structure from android studio (suggestion option and instead of using + in the version put the version no)
  2. npm cache
  3. if debugging from mobile be sure developer mode should be switch off and on. Or else try with another device.
  4. i also deleted my npm_module and fresh install the npm packages but be sure to clean the npm cache.

@wontone18 glad you found a solution.

Currently React Native is not supporting Gradle 7.0, we are using v6.6. Is there any specific reason you need v7 support at this time?

@wontone18 glad you found a solution.

Currently React Native is not supporting Gradle 7.0, we are using v6.6. Is there any specific reason you need v7 support at this time?

nah i am not using gradle 7 at all. React native already having a gradle plugin package in gradle wrapper. which is 6 but based on jdk version.

@wontone18 glad you found a solution.
Currently React Native is not supporting Gradle 7.0, we are using v6.6. Is there any specific reason you need v7 support at this time?

nah i am not using gradle 7 at all. React native already having a gradle plugin package in gradle wrapper. which is 6 but based on jdk version.

Has anyone managed to solve this problem? I tried everything I found in this post and others, but without success.

I solved the error creating a new 'react-native init' with the same name of the app, in another folder. Then I deleted the android folder of my app, and pasted the android folder of the new app. Now everything is working again.

@wontone18 glad you found a solution.
Currently React Native is not supporting Gradle 7.0, we are using v6.6. Is there any specific reason you need v7 support at this time?

nah i am not using gradle 7 at all. React native already having a gradle plugin package in gradle wrapper. which is 6 but based on jdk version.

Has anyone managed to solve this problem? I tried everything I found in this post and others, but without success.

I solved the error creating a new 'react-native init' with the same name of the app, in another folder. Then I deleted the android folder of my app, and pasted the android folder of the new app. Now everything is working again.

Hi at last issue is resolve.

Based on the fact that original issue filer seems unblocked, closing this issue.

I ran into the same error while debugging from the phone. The cause was I had manually uploaded and installed my app apk. After deleting the app from the phone, and all was fine after

Do we have a boiler plate code to fix these incompatible issues for RN setup?

for me the ./greadlew clean worked

I had the same error and fixed it by deleting the \android\appbuild\generated\not_namespaced_r_class_sourcesdebug\r\androidx folder. It was empty and saw something about not being able to delete this folder in the error text.
If that does not work, please try PereiraDiegoMiguel answer.
NOTE: React Native seems to have no problem building with the gradle errors. So expect to look for other errors than just gradle errors. I still get the gradle 7.0 error but it builds fine.

I have the same problem :c

Hello everyone,

Just sharing my experience as I could solve it on my side, so if it can help...

Context:
THIS IS A NEW ERROR. I had not touched RN for a while and I just wanted to create a new project. I got the same error only after running react-native init and react-native run-android.

Solution:

  • I followed this previous answer on a similar issue
  • This brought to the Gradle versions correspondances
  • I updated the classpath("com.android.tools.build:gradle:X.X.X") in android/build.gradle (it was version 3.5.3, I now use version 4.1.0)
  • The next triggered error required to update gradle from verion 6.2 to 6.5. So, I updated distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip in android/gradle/wrapper/gradle-wrapper.properties

If you still have other errors that you did not have in the past, please notice that you may need to:

  • touch /home/$USER/.android/repositories.cfg
  • sudo chown $USER:$USER $ANDROID_HOME -R
  • Update your SDK (using /opt/android/tools/android update sdk --no-ui --all --filter "android-XX" using an adapted version, currently "android-29" works well)
  • Accept licences you had not accepted before (using /opt/android/tools/bin/sdkmanager --licenses)

I hope it could help as I know it is not pleasant to just try to start a project needing to fix things.

Was this page helpful?
0 / 5 - 0 ratings