'React native app installation fails on Andoid

I just created a new react-native project and I'm getting the following error when trying to run it on android or running gradlew clean:

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
FAILURE: Build failed with an exception.

* What went wrong:
Could not create an instance of type org.gradle.kotlin.dsl.provider.KotlinScriptPluginFactory.
> Could not create service of type KotlinDslWorkspaceProvider using GradleUserHomeServices.createKotlinDslWorkspaceProvider().
   > Unexpected lock protocol found in lock file. Expected 3, found 0.

After trying to start an old react-native app I noticed I can't install any app at the moment, so there's probably a mistake outside my project.

Did anyone experience something like that already?



Solution 1:[1]

I fixed it by using Java 11 instead of java 8.

I deleted the gradle cashe and then got a new error telling me to use java 11.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 JaRoMaster