facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.25k stars 24.34k forks source link

Failed to apply plugin 'com.facebook.react' #41580

Closed harrymash2006 closed 11 months ago

harrymash2006 commented 11 months ago

Description

After I upgraded the react native to 0.73.0-rc.4 it started giving this error

Failed to apply plugin 'com.facebook.react'.> The value for property 'languageVersion' is final and cannot be changed any further.

React Native Version

0.73.0-rc.4

Output of npx react-native info

System: OS: macOS 14.1.1 CPU: (12) arm64 Apple M2 Max Memory: 82.88 MB / 32.00 GB Shell: version: "5.9" path: /bin/zsh Binaries: Node: version: 18.18.0 path: ~/.nvm/versions/node/v18.18.0/bin/node Yarn: version: 1.22.19 path: /opt/homebrew/bin/yarn npm: version: 9.8.1 path: ~/.nvm/versions/node/v18.18.0/bin/npm Watchman: version: 2023.10.02.00 path: /opt/homebrew/bin/watchman Managers: CocoaPods: version: 1.13.0 path: /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms:

Steps to reproduce

fails at android sync

Snack, screenshot, or link to a repository

Screenshot_2023-11-21_at_5_36_43 PM
github-actions[bot] commented 11 months ago
:warning: Missing Reproducible Example
:information_source: We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.
cortinico commented 11 months ago

Can you provide a reproducer? @harrymash2006 Is this happening an a empty project?

harrymash2006 commented 11 months ago

Sorry, I think this is not an issue on react native side. It just happens when I try to add a local custom module, so closing this.

feng-yu-healthbank commented 11 months ago

@harrymash2006 could you shed me some light which module caused this error? I simply upgraded react-native from 0.72.5 to 0.73.1 and started getting this error

caltseng commented 10 months ago

We are running into this also when upgrading to RN 0.73.0 - would love to know how this was resolved for you.

pprraasshhaanntthh commented 10 months ago

Has anyone found a solution for this yet?

azizmobarak commented 10 months ago

the same here

victor-chan-groundswell commented 8 months ago

So I'm running into this when I'm trying to gradle 8 to run after upgrading to RN 0.7.3 (yes, I got it to build using gradle 7.6.4)... When I upgraded to gradle 8.0, I ran into this with one of my other packages

A problem occurred configuring project ':amplitude_analytics-react-native'.

com.android.builder.errors.EvalIssueException: defaultConfig contains custom BuildConfig fields, but the feature is disabled. To enable the feature, add the following to your module-level build.gradle: android.buildFeatures.buildConfig true

So I tried to apply the configuration per what I googled.

https://stackoverflow.com/questions/74634321/fixing-the-build-type-contains-custom-buildconfig-fields-but-the-feature-is-di

When that is apply this setting

android.defaults.buildfeatures.buildconfig=true

However, then I see

Failed to apply plugin 'com.facebook.react'. The value for property 'languageVersion' is final and cannot be changed any further.

My guess is some sort of incompatibility between competing packages wanting different things.

NomanGul commented 8 months ago

I'm also facing this issue

VelocityPulse commented 7 months ago

Same here, can't find any solution.. I've been looking during days

elisjoaquim commented 7 months ago

Same here! Has someone find a solution on this?

C2418M31 commented 6 months ago

I also have the same issue.

AGP = 8.3.2 Gradke = 8.4

"devDependencies": { "@babel/core": "^7.20.0", "@babel/preset-env": "^7.20.0", "@babel/runtime": "^7.20.0", "@react-native/babel-preset": "0.73.21", "@react-native/eslint-config": "0.73.2", "@react-native/metro-config": "0.73.5", "@react-native/typescript-config": "0.73.1", "@types/react": "^18.2.6", "@types/react-test-renderer": "^18.0.0", "babel-jest": "^29.6.3", "eslint": "^8.19.0", "jest": "^29.6.3", "prettier": "2.8.8", "react-test-renderer": "18.2.0", "typescript": "5.0.4" }

image

elisjoaquim commented 6 months ago

Hey @C2418M31, 2 days ago I stumbled upon the same error. The explanation is the following, the new Gradle Version throws this error when there are updates on languageVersion, which is set through this configs in the gradle:

android {
 compileOptions {
            sourceCompatibility JavaVersion.VERSION_[any version]
            targetCompatibility JavaVersion.VERSION_[any version]
        }

        kotlinOptions {
            jvmTarget = "[kotlin_version]"
        }
}

It's because the new React Native version has already the base version set, you can check this out in your project node module folder: node_modules/@react-native/gradle-plugin/src/main/kotlin/com/facebook/react/utils/JdkConfiguratorUtils.kt.

You have two ways to solve it, chose one of them:

  1. Patch the React Native gradle configs by commenting out the lines setting the version

    
    internal object JdkConfiguratorUtils {
    
    fun configureJavaToolChains(input: Project) {
    // Check at the app level if react.internal.disableJavaVersionAlignment is set.
    if (input.hasProperty(INTERNAL_DISABLE_JAVA_VERSION_ALIGNMENT)) {
      return
    }
    input.rootProject.allprojects { project ->
      // Allows every single module to set react.internal.disableJavaVersionAlignment also.
      if (project.hasProperty(INTERNAL_DISABLE_JAVA_VERSION_ALIGNMENT)) {
        return@allprojects
      }
      val action =
          Action<AppliedPlugin> {
            /*project.extensions.getByType(AndroidComponentsExtension::class.java).finalizeDsl { ext
              ->
              ext.compileOptions.sourceCompatibility = JavaVersion.VERSION_17
              ext.compileOptions.targetCompatibility = JavaVersion.VERSION_17
            }*/ -> these lines out
          }
      project.pluginManager.withPlugin("com.android.application", action)
      project.pluginManager.withPlugin("com.android.library", action)
      project.pluginManager.withPlugin("org.jetbrains.kotlin.android") {
        // project.extensions.getByType(KotlinTopLevelExtension::class.java).jvmToolchain(17) -> this line out
      }
      project.pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
       // project.extensions.getByType(KotlinTopLevelExtension::class.java).jvmToolchain(17) -> this line out
      }
    }
    }
    }
    ``` (not recommended)
  2. Remove these declarations for version update from your gradle file.
  3. Use a different Gradle Version that does not throw this error, check here with version does not do that https://docs.gradle.org/current/userguide/upgrading_version_8.html
C2418M31 commented 6 months ago

Hi @elisjoaquim I tried the two ways.

1: I tried to commented the

ext.compileOptions.sourceCompatibility = JavaVersion.VERSION_17
ext.compileOptions.targetCompatibility = JavaVersion.VERSION_17

and the

project.extensions.getByType(KotlinTopLevelExtension::class.java).jvmToolchain(17)
project.extensions.getByType(KotlinTopLevelExtension::class.java).jvmToolchain(17)

and in my app gradle.kts file i retain the compile options.

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }

    kotlinOptions {
        jvmTarget = "17"
    }`

And the result was: Build was configured to prefer settings repositories over project repositories but repository 'maven' was added by plugin 'com.facebook.react'

in my settings.gradle.kts. :

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven {
            url = uri("https://jitpack.io")
        }
        maven {
            url = uri("https://developer.huawei.com/repo/")
        }
        maven {
            url = uri("https://dk231gpcvg3h6c.cloudfront.net/android")
        }
    }
}

2: I tried the 2nd suggestion and remove in the app gradle.kts the compile options and retain in the node_modules the verison 17. and the output still the same with number 1. conflicting now with the settings repository.

Thank @elisjoaquim you give a good insight about this.

elisjoaquim commented 6 months ago

Hello @C2418M31, the previous issues seems to be solved, it now has to do with the dependency resolution configs you are using for Gradle. Suggestion, remove this declaration from your setting.gradle file and add the following to the build.gradle:

allprojects {
    repositories {
        google()
        mavenCentral()
        maven {
            url = uri("https://jitpack.io")
        }
        maven {
            url = uri("https://developer.huawei.com/repo/")
        }
        maven {
            url = uri("https://dk231gpcvg3h6c.cloudfront.net/android")
        }
    }
}

Thanks!

fadi-quader-mox commented 6 months ago

I'm encountering this error after i bumped to 0.73.8. my android has two modules app and instant-app. Is there any way to fix this issue?

pavelglebov commented 5 months ago

Have the same issue with gradle 8.2 and react native 0.72.10. Looks like this issue is actual and appears often, can you @harrymash2006 or @cortinico reopen the issue?

Bekaxp commented 5 months ago

Hi, I did the same:

Screenshot 2024-06-01 at 11 11 37

and here is the Gradle info: Screenshot 2024-06-01 at 11 21 56

If I find something useful I will report back here.

Thank you

C2418M31 commented 5 months ago

Hi, I did the same:

  • Init a new react-native project with react-native 0.74.1
  • Added (copied) a new module
  • When gradle tries to build it it fails with Caused by: java.lang.IllegalStateException: The value for property 'languageVersion' is final and cannot be changed any further.

Screenshot 2024-06-01 at 11 11 37

and here is the Gradle info: Screenshot 2024-06-01 at 11 21 56

If I find something useful I will report back here.

Thank you

Can you show the full logcat?

or try to go to the file-> settings -> build tools and select appropriate jdk version then resync gradle.

Bekaxp commented 5 months ago

Hi, I did the same:

  • Init a new react-native project with react-native 0.74.1
  • Added (copied) a new module
  • When gradle tries to build it it fails with Caused by: java.lang.IllegalStateException: The value for property 'languageVersion' is final and cannot be changed any further.

Screenshot 2024-06-01 at 11 11 37 and here is the Gradle info: Screenshot 2024-06-01 at 11 21 56 If I find something useful I will report back here. Thank you

Can you show the full logcat?

or try to go to the file-> settings -> build tools and select appropriate jdk version then resync gradle.

Of course... here it is:

A problem occurred evaluating project ':appInstant'.
> Failed to apply plugin 'com.facebook.react'.
> The value for property 'languageVersion' is final and cannot be changed any further.

* Try:
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating project ':appInstant'.
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:93)
at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.lambda$apply$0(DefaultScriptPluginFactory.java:136)
at org.gradle.configuration.ProjectScriptTarget.addConfiguration(ProjectScriptTarget.java:79)
at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:139)
at org.gradle.configuration.BuildOperationScriptPlugin$1.run(BuildOperationScriptPlugin.java:68)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:47)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:68)
at org.gradle.configuration.BuildOperationScriptPlugin.lambda$apply$0(BuildOperationScriptPlugin.java:65)
at org.gradle.internal.code.DefaultUserCodeApplicationContext.apply(DefaultUserCodeApplicationContext.java:43)
at org.gradle.configuration.BuildOperationScriptPlugin.apply(BuildOperationScriptPlugin.java:65)
at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.lambda$applyToMutableState$1(DefaultProjectStateRegistry.java:407)
at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.fromMutableState(DefaultProjectStateRegistry.java:425)
at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.applyToMutableState(DefaultProjectStateRegistry.java:406)
at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:46)
at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:27)
at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:35)
at org.gradle.configuration.project.LifecycleProjectEvaluator$EvaluateProject.lambda$run$0(LifecycleProjectEvaluator.java:109)
at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.lambda$applyToMutableState$1(DefaultProjectStateRegistry.java:407)
at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.lambda$fromMutableState$2(DefaultProjectStateRegistry.java:430)
at org.gradle.internal.work.DefaultWorkerLeaseService.withReplacedLocks(DefaultWorkerLeaseService.java:360)
at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.fromMutableState(DefaultProjectStateRegistry.java:430)
at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.applyToMutableState(DefaultProjectStateRegistry.java:406)
at org.gradle.configuration.project.LifecycleProjectEvaluator$EvaluateProject.run(LifecycleProjectEvaluator.java:100)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:47)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:68)
at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:72)
at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:789)
at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:155)
at org.gradle.api.internal.project.ProjectLifecycleController.lambda$ensureSelfConfigured$2(ProjectLifecycleController.java:84)
at org.gradle.internal.model.StateTransitionController.lambda$doTransition$14(StateTransitionController.java:255)
at org.gradle.internal.model.StateTransitionController.doTransition(StateTransitionController.java:266)
at org.gradle.internal.model.StateTransitionController.doTransition(StateTransitionController.java:254)
at org.gradle.internal.model.StateTransitionController.lambda$maybeTransitionIfNotCurrentlyTransitioning$10(StateTransitionController.java:199)
at org.gradle.internal.work.DefaultSynchronizer.withLock(DefaultSynchronizer.java:34)
at org.gradle.internal.model.StateTransitionController.maybeTransitionIfNotCurrentlyTransitioning(StateTransitionController.java:195)
at org.gradle.api.internal.project.ProjectLifecycleController.ensureSelfConfigured(ProjectLifecycleController.java:84)
at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.ensureConfigured(DefaultProjectStateRegistry.java:381)
at org.gradle.execution.TaskPathProjectEvaluator.configure(TaskPathProjectEvaluator.java:34)
at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:50)
at org.gradle.configuration.DefaultProjectsPreparer.prepareProjects(DefaultProjectsPreparer.java:42)
at org.gradle.configuration.BuildTreePreparingProjectsPreparer.prepareProjects(BuildTreePreparingProjectsPreparer.java:65)
at org.gradle.configuration.BuildOperationFiringProjectsPreparer$ConfigureBuild.run(BuildOperationFiringProjectsPreparer.java:52)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:47)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:68)
at org.gradle.configuration.BuildOperationFiringProjectsPreparer.prepareProjects(BuildOperationFiringProjectsPreparer.java:40)
at org.gradle.initialization.VintageBuildModelController.lambda$prepareProjects$2(VintageBuildModelController.java:84)
at org.gradle.internal.model.StateTransitionController.lambda$doTransition$14(StateTransitionController.java:255)
at org.gradle.internal.model.StateTransitionController.doTransition(StateTransitionController.java:266)
at org.gradle.internal.model.StateTransitionController.doTransition(StateTransitionController.java:254)
at org.gradle.internal.model.StateTransitionController.lambda$transitionIfNotPreviously$11(StateTransitionController.java:213)
at org.gradle.internal.work.DefaultSynchronizer.withLock(DefaultSynchronizer.java:34)
at org.gradle.internal.model.StateTransitionController.transitionIfNotPreviously(StateTransitionController.java:209)
at org.gradle.initialization.VintageBuildModelController.prepareProjects(VintageBuildModelController.java:84)
at org.gradle.initialization.VintageBuildModelController.getConfiguredModel(VintageBuildModelController.java:64)
at org.gradle.internal.build.DefaultBuildLifecycleController.lambda$withProjectsConfigured$1(DefaultBuildLifecycleController.java:133)
at org.gradle.internal.model.StateTransitionController.lambda$notInState$3(StateTransitionController.java:132)
at org.gradle.internal.work.DefaultSynchronizer.withLock(DefaultSynchronizer.java:44)
at org.gradle.internal.model.StateTransitionController.notInState(StateTransitionController.java:128)
at org.gradle.internal.build.DefaultBuildLifecycleController.withProjectsConfigured(DefaultBuildLifecycleController.java:133)
at org.gradle.internal.build.DefaultBuildToolingModelController.locateBuilderForTarget(DefaultBuildToolingModelController.java:58)
at org.gradle.internal.buildtree.DefaultBuildTreeModelCreator$DefaultBuildTreeModelController.lambda$locateBuilderForTarget$0(DefaultBuildTreeModelCreator.java:64)
at org.gradle.internal.build.DefaultBuildLifecycleController.withToolingModels(DefaultBuildLifecycleController.java:327)
at org.gradle.internal.build.AbstractBuildState.withToolingModels(AbstractBuildState.java:146)
at org.gradle.internal.buildtree.DefaultBuildTreeModelCreator$DefaultBuildTreeModelController.locateBuilderForTarget(DefaultBuildTreeModelCreator.java:64)
at org.gradle.internal.buildtree.DefaultBuildTreeModelCreator$DefaultBuildTreeModelController.locateBuilderForDefaultTarget(DefaultBuildTreeModelCreator.java:59)
at org.gradle.tooling.internal.provider.runner.DefaultBuildController.getTarget(DefaultBuildController.java:136)
at org.gradle.tooling.internal.provider.runner.DefaultBuildController.getModel(DefaultBuildController.java:107)
at org.gradle.tooling.internal.consumer.connection.ParameterAwareBuildControllerAdapter.getModel(ParameterAwareBuildControllerAdapter.java:39)
at org.gradle.tooling.internal.consumer.connection.UnparameterizedBuildController.getModel(UnparameterizedBuildController.java:113)
at org.gradle.tooling.internal.consumer.connection.NestedActionAwareBuildControllerAdapter.getModel(NestedActionAwareBuildControllerAdapter.java:31)
at org.gradle.tooling.internal.consumer.connection.UnparameterizedBuildController.findModel(UnparameterizedBuildController.java:97)
at org.gradle.tooling.internal.consumer.connection.NestedActionAwareBuildControllerAdapter.findModel(NestedActionAwareBuildControllerAdapter.java:31)
at org.gradle.tooling.internal.consumer.connection.UnparameterizedBuildController.findModel(UnparameterizedBuildController.java:81)
at org.gradle.tooling.internal.consumer.connection.NestedActionAwareBuildControllerAdapter.findModel(NestedActionAwareBuildControllerAdapter.java:31)
at org.gradle.tooling.internal.consumer.connection.UnparameterizedBuildController.findModel(UnparameterizedBuildController.java:66)
at org.gradle.tooling.internal.consumer.connection.NestedActionAwareBuildControllerAdapter.findModel(NestedActionAwareBuildControllerAdapter.java:31)
at org.jetbrains.plugins.gradle.model.ProjectImportAction.doExecute(ProjectImportAction.java:117)
at org.jetbrains.plugins.gradle.model.ProjectImportAction.execute(ProjectImportAction.java:91)
at org.jetbrains.plugins.gradle.model.ProjectImportAction.execute(ProjectImportAction.java:39)
at org.gradle.tooling.internal.consumer.connection.InternalBuildActionAdapter.execute(InternalBuildActionAdapter.java:64)
at org.gradle.tooling.internal.provider.runner.AbstractClientProvidedBuildActionRunner$ActionAdapter.runAction(AbstractClientProvidedBuildActionRunner.java:131)
at org.gradle.tooling.internal.provider.runner.AbstractClientProvidedBuildActionRunner$ActionAdapter.beforeTasks(AbstractClientProvidedBuildActionRunner.java:99)
at org.gradle.internal.buildtree.DefaultBuildTreeModelCreator.beforeTasks(DefaultBuildTreeModelCreator.java:43)
at org.gradle.internal.buildtree.DefaultBuildTreeLifecycleController.lambda$fromBuildModel$2(DefaultBuildTreeLifecycleController.java:82)
at org.gradle.internal.buildtree.DefaultBuildTreeLifecycleController.lambda$runBuild$4(DefaultBuildTreeLifecycleController.java:119)
at org.gradle.internal.model.StateTransitionController.lambda$transition$6(StateTransitionController.java:169)
at org.gradle.internal.model.StateTransitionController.doTransition(StateTransitionController.java:266)
at org.gradle.internal.model.StateTransitionController.lambda$transition$7(StateTransitionController.java:169)
at org.gradle.internal.work.DefaultSynchronizer.withLock(DefaultSynchronizer.java:44)
at org.gradle.internal.model.StateTransitionController.transition(StateTransitionController.java:169)
at org.gradle.internal.buildtree.DefaultBuildTreeLifecycleController.runBuild(DefaultBuildTreeLifecycleController.java:116)
at org.gradle.internal.buildtree.DefaultBuildTreeLifecycleController.fromBuildModel(DefaultBuildTreeLifecycleController.java:81)
at org.gradle.tooling.internal.provider.runner.AbstractClientProvidedBuildActionRunner.runClientAction(AbstractClientProvidedBuildActionRunner.java:43)
at org.gradle.tooling.internal.provider.runner.ClientProvidedPhasedActionRunner.run(ClientProvidedPhasedActionRunner.java:53)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.internal.buildtree.ProblemReportingBuildActionRunner.run(ProblemReportingBuildActionRunner.java:49)
at org.gradle.launcher.exec.BuildOutcomeReportingBuildActionRunner.run(BuildOutcomeReportingBuildActionRunner.java:65)
at org.gradle.tooling.internal.provider.FileSystemWatchingBuildActionRunner.run(FileSystemWatchingBuildActionRunner.java:140)
at org.gradle.launcher.exec.BuildCompletionNotifyingBuildActionRunner.run(BuildCompletionNotifyingBuildActionRunner.java:41)
at org.gradle.launcher.exec.RootBuildLifecycleBuildActionExecutor.lambda$execute$0(RootBuildLifecycleBuildActionExecutor.java:40)
at org.gradle.composite.internal.DefaultRootBuildState.run(DefaultRootBuildState.java:123)
at org.gradle.launcher.exec.RootBuildLifecycleBuildActionExecutor.execute(RootBuildLifecycleBuildActionExecutor.java:40)
at org.gradle.internal.buildtree.InitDeprecationLoggingActionExecutor.execute(InitDeprecationLoggingActionExecutor.java:62)
at org.gradle.internal.buildtree.InitProblems.execute(InitProblems.java:38)
at org.gradle.internal.buildtree.DefaultBuildTreeContext.execute(DefaultBuildTreeContext.java:40)
at org.gradle.launcher.exec.BuildTreeLifecycleBuildActionExecutor.lambda$execute$0(BuildTreeLifecycleBuildActionExecutor.java:71)
at org.gradle.internal.buildtree.BuildTreeState.run(BuildTreeState.java:60)
at org.gradle.launcher.exec.BuildTreeLifecycleBuildActionExecutor.execute(BuildTreeLifecycleBuildActionExecutor.java:71)
at org.gradle.launcher.exec.RunAsBuildOperationBuildActionExecutor$3.call(RunAsBuildOperationBuildActionExecutor.java:61)
at org.gradle.launcher.exec.RunAsBuildOperationBuildActionExecutor$3.call(RunAsBuildOperationBuildActionExecutor.java:57)
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73)
at org.gradle.launcher.exec.RunAsBuildOperationBuildActionExecutor.execute(RunAsBuildOperationBuildActionExecutor.java:57)
at org.gradle.launcher.exec.RunAsWorkerThreadBuildActionExecutor.lambda$execute$0(RunAsWorkerThreadBuildActionExecutor.java:36)
at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:264)
at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:128)
at org.gradle.launcher.exec.RunAsWorkerThreadBuildActionExecutor.execute(RunAsWorkerThreadBuildActionExecutor.java:36)
at org.gradle.tooling.internal.provider.continuous.ContinuousBuildActionExecutor.execute(ContinuousBuildActionExecutor.java:110)
at org.gradle.tooling.internal.provider.SubscribableBuildActionExecutor.execute(SubscribableBuildActionExecutor.java:64)
at org.gradle.internal.session.DefaultBuildSessionContext.execute(DefaultBuildSessionContext.java:46)
at org.gradle.tooling.internal.provider.BuildSessionLifecycleBuildActionExecuter$ActionImpl.apply(BuildSessionLifecycleBuildActionExecuter.java:92)
at org.gradle.tooling.internal.provider.BuildSessionLifecycleBuildActionExecuter$ActionImpl.apply(BuildSessionLifecycleBuildActionExecuter.java:80)
at org.gradle.internal.session.BuildSessionState.run(BuildSessionState.java:69)
at org.gradle.tooling.internal.provider.BuildSessionLifecycleBuildActionExecuter.execute(BuildSessionLifecycleBuildActionExecuter.java:62)
at org.gradle.tooling.internal.provider.BuildSessionLifecycleBuildActionExecuter.execute(BuildSessionLifecycleBuildActionExecuter.java:41)
at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:64)
at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:32)
at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:51)
at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:39)
at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:47)
at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:31)
at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:65)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:37)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:39)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:29)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:35)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.create(ForwardClientInput.java:78)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.create(ForwardClientInput.java:75)
at org.gradle.util.internal.Swapper.swap(Swapper.java:38)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:75)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:64)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:63)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:37)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:84)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:37)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:52)
at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
at org.gradle.internal.concurrent.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:47)
Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin 'com.facebook.react'.
at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:176)
at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:148)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyType(DefaultObjectConfigurationAction.java:161)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:43)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:98)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:184)
at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:49)
at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.java:37)
at org.gradle.api.Script$apply.callCurrent(Unknown Source)
at build_3e1wjhvfajncfw7b19rv5ujfu.run(/Users/iam/dev/app/android/appInstant/build.gradle:3)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:91)
... 180 more
Caused by: java.lang.IllegalStateException: The value for property 'languageVersion' is final and cannot be changed any further.
at org.gradle.api.internal.provider.ValueState$FinalizedValue.beforeMutate(ValueState.java:247)
at org.gradle.api.internal.provider.AbstractProperty.assertCanMutate(AbstractProperty.java:284)
at org.gradle.api.internal.provider.AbstractProperty.setSupplier(AbstractProperty.java:231)
at org.gradle.api.internal.provider.DefaultProperty.set(DefaultProperty.java:72)
at org.jetbrains.kotlin.gradle.dsl.KotlinTopLevelExtension$jvmToolchain$1.execute(KotlinProjectExtension.kt:97)
at org.jetbrains.kotlin.gradle.dsl.KotlinTopLevelExtension$jvmToolchain$1.execute(KotlinProjectExtension.kt:96)
at org.jetbrains.kotlin.gradle.dsl.DefaultToolchainSupport.applyToolchain(ToolchainDsl.kt:59)
at org.jetbrains.kotlin.gradle.dsl.KotlinTopLevelExtension.jvmToolchain(KotlinProjectExtension.kt:87)
at org.jetbrains.kotlin.gradle.dsl.KotlinTopLevelExtension.jvmToolchain(KotlinProjectExtension.kt:96)
at com.facebook.react.utils.JdkConfiguratorUtils$configureJavaToolChains$1$1.invoke(JdkConfiguratorUtils.kt:45)
at com.facebook.react.utils.JdkConfiguratorUtils$configureJavaToolChains$1$1.invoke(JdkConfiguratorUtils.kt:44)
at com.facebook.react.utils.JdkConfiguratorUtils$configureJavaToolChains$1.invoke$lambda$1(JdkConfiguratorUtils.kt:44)
at org.gradle.api.internal.plugins.DefaultPluginManager$2.execute(DefaultPluginManager.java:261)
at org.gradle.api.internal.plugins.DefaultPluginManager$2.execute(DefaultPluginManager.java:258)
at org.gradle.internal.code.DefaultUserCodeApplicationContext$CurrentApplication$1.execute(DefaultUserCodeApplicationContext.java:122)
at org.gradle.api.internal.DefaultCollectionCallbackActionDecorator$BuildOperationEmittingAction$1.run(DefaultCollectionCallbackActionDecorator.java:110)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:47)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:68)
at org.gradle.api.internal.DefaultCollectionCallbackActionDecorator$BuildOperationEmittingAction.execute(DefaultCollectionCallbackActionDecorator.java:107)
at org.gradle.api.internal.DefaultDomainObjectCollection.all(DefaultDomainObjectCollection.java:161)
at org.gradle.api.internal.plugins.DefaultPluginManager.withPlugin(DefaultPluginManager.java:264)
at com.facebook.react.utils.JdkConfiguratorUtils$configureJavaToolChains$1.invoke(JdkConfiguratorUtils.kt:44)
at com.facebook.react.utils.JdkConfiguratorUtils$configureJavaToolChains$1.invoke(JdkConfiguratorUtils.kt:29)
at com.facebook.react.utils.JdkConfiguratorUtils.configureJavaToolChains$lambda$0(JdkConfiguratorUtils.kt:29)
at org.gradle.api.internal.DefaultMutationGuard$1.execute(DefaultMutationGuard.java:45)
at org.gradle.internal.Actions.with(Actions.java:206)
at org.gradle.api.internal.project.BuildOperationCrossProjectConfigurator$1.run(BuildOperationCrossProjectConfigurator.java:69)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:47)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:68)
at org.gradle.api.internal.project.BuildOperationCrossProjectConfigurator.lambda$runProjectConfigureAction$0(BuildOperationCrossProjectConfigurator.java:66)
at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.lambda$applyToMutableState$1(DefaultProjectStateRegistry.java:407)
at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.fromMutableState(DefaultProjectStateRegistry.java:425)
at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.applyToMutableState(DefaultProjectStateRegistry.java:406)
at org.gradle.api.internal.project.BuildOperationCrossProjectConfigurator.runProjectConfigureAction(BuildOperationCrossProjectConfigurator.java:66)
at org.gradle.api.internal.project.BuildOperationCrossProjectConfigurator.access$100(BuildOperationCrossProjectConfigurator.java:32)
at org.gradle.api.internal.project.BuildOperationCrossProjectConfigurator$BlockConfigureBuildOperation.run(BuildOperationCrossProjectConfigurator.java:111)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:47)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:68)
at org.gradle.api.internal.project.BuildOperationCrossProjectConfigurator.runBlockConfigureAction(BuildOperationCrossProjectConfigurator.java:62)
at org.gradle.api.internal.project.BuildOperationCrossProjectConfigurator.allprojects(BuildOperationCrossProjectConfigurator.java:53)
at org.gradle.api.internal.project.DefaultProject.allprojects(DefaultProject.java:730)
at org.gradle.api.internal.project.DefaultProject.allprojects(DefaultProject.java:725)
at com.facebook.react.utils.JdkConfiguratorUtils.configureJavaToolChains(JdkConfiguratorUtils.kt:29)
at com.facebook.react.ReactPlugin$apply$1.invoke(ReactPlugin.kt:74)
at com.facebook.react.ReactPlugin$apply$1.invoke(ReactPlugin.kt:52)
at com.facebook.react.ReactPlugin.apply$lambda$0(ReactPlugin.kt:52)
at org.gradle.api.internal.plugins.DefaultPluginManager$2.execute(DefaultPluginManager.java:261)
at org.gradle.api.internal.plugins.DefaultPluginManager$2.execute(DefaultPluginManager.java:258)
at org.gradle.internal.code.DefaultUserCodeApplicationContext$CurrentApplication$1.execute(DefaultUserCodeApplicationContext.java:122)
at org.gradle.api.internal.DefaultCollectionCallbackActionDecorator$BuildOperationEmittingAction$1.run(DefaultCollectionCallbackActionDecorator.java:110)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:47)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:68)
at org.gradle.api.internal.DefaultCollectionCallbackActionDecorator$BuildOperationEmittingAction.execute(DefaultCollectionCallbackActionDecorator.java:107)
at org.gradle.api.internal.DefaultDomainObjectCollection.all(DefaultDomainObjectCollection.java:161)
at org.gradle.api.internal.plugins.DefaultPluginManager.withPlugin(DefaultPluginManager.java:264)
at com.facebook.react.ReactPlugin.apply(ReactPlugin.kt:52)
at com.facebook.react.ReactPlugin.apply(ReactPlugin.kt:38)
at org.gradle.api.internal.plugins.ImperativeOnlyPluginTarget.applyImperative(ImperativeOnlyPluginTarget.java:43)
at org.gradle.api.internal.plugins.RuleBasedPluginTarget.applyImperative(RuleBasedPluginTarget.java:51)
at org.gradle.api.internal.plugins.DefaultPluginManager.addPlugin(DefaultPluginManager.java:190)
at org.gradle.api.internal.plugins.DefaultPluginManager.access$100(DefaultPluginManager.java:54)
at org.gradle.api.internal.plugins.DefaultPluginManager$AddPluginBuildOperation.run(DefaultPluginManager.java:285)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:47)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:68)
at org.gradle.api.internal.plugins.DefaultPluginManager.lambda$doApply$0(DefaultPluginManager.java:170)
at org.gradle.internal.code.DefaultUserCodeApplicationContext.apply(DefaultUserCodeApplicationContext.java:43)
at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:169)
... 190 more

Thanks!

Bekaxp commented 5 months ago

Interesting... I tried what @elisjoaquim suggested. To comment out the code in JdkConfigurationUtils.kt which sets the JAVA version internally. And now Gradle was able to sync properly.

darthgween commented 4 months ago

Hi there! I tried what @elisjoaquim suggested too (Comment out some lines in JdkConfiguratorUtils.kt). In an empty RN app everything works fine, app and InstantApp as well, but then when I import and use libraries like react-native-screens, react-native-safe-area-context and others I got the following error:

Execution failed for task ':react-native-screens:compileDebugKotlin'.

Inconsistent JVM-target compatibility detected for tasks 'compileDebugJavaWithJavac' (1.8) and 'compileDebugKotlin' (17).

I'm sure that this error is caused by commenting out that lines in JdkConfiguratorUtils.kt (I tested it) Any Ideas how to solve it? Please help :'(

fadi-quader-mox commented 4 months ago

i patched @react-native/gradle-plugin/src/main/kotlin/com/facebook/react/utils/JdkConfiguratorUtils.kt with the one in React Native 0.72.9 and it worked

diff --git a/node_modules/@react-native/gradle-plugin/src/main/kotlin/com/facebook/react/utils/JdkConfiguratorUtils.kt b/node_modules/@react-native/gradle-plugin/src/main/kotlin/com/facebook/react/utils/JdkConfiguratorUtils.kt
index 0d55714..e79f0e9 100644
--- a/node_modules/@react-native/gradle-plugin/src/main/kotlin/com/facebook/react/utils/JdkConfiguratorUtils.kt
+++ b/node_modules/@react-native/gradle-plugin/src/main/kotlin/com/facebook/react/utils/JdkConfiguratorUtils.kt
@@ -15,6 +15,7 @@ import org.gradle.api.Project
 import org.gradle.api.plugins.AppliedPlugin
 import org.jetbrains.kotlin.gradle.dsl.KotlinTopLevelExtension

+// revert this file to RN 0.72 to fix https://github.com/facebook/react-native/issues/41580
 internal object JdkConfiguratorUtils {
   /**
    * Function that takes care of configuring the JDK toolchain for all the projects projects. As we
@@ -22,31 +23,26 @@ internal object JdkConfiguratorUtils {
    * configure the toolchain to 17.
    */
   fun configureJavaToolChains(input: Project) {
-    // Check at the app level if react.internal.disableJavaVersionAlignment is set.
     if (input.hasProperty(INTERNAL_DISABLE_JAVA_VERSION_ALIGNMENT)) {
       return
     }
     input.rootProject.allprojects { project ->
-      // Allows every single module to set react.internal.disableJavaVersionAlignment also.
-      if (project.hasProperty(INTERNAL_DISABLE_JAVA_VERSION_ALIGNMENT)) {
-        return@allprojects
-      }
       val action =
           Action<AppliedPlugin> {
-            project.extensions.getByType(AndroidComponentsExtension::class.java).finalizeDsl { ext
-              ->
+            project.extensions.getByType(AndroidComponentsExtension::class.java).finalizeDsl {
+                ext ->
               ext.compileOptions.sourceCompatibility = JavaVersion.VERSION_17
               ext.compileOptions.targetCompatibility = JavaVersion.VERSION_17
             }
           }
       project.pluginManager.withPlugin("com.android.application", action)
       project.pluginManager.withPlugin("com.android.library", action)
-      project.pluginManager.withPlugin("org.jetbrains.kotlin.android") {
-        project.extensions.getByType(KotlinTopLevelExtension::class.java).jvmToolchain(17)
-      }
-      project.pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
-        project.extensions.getByType(KotlinTopLevelExtension::class.java).jvmToolchain(17)
-      }
     }
+    // We set kotlin.jvm.target.validation.mode=warning on the root projects, as for projects
+    // on Gradle 8+ and Kotlin 1.8+ this value is set to `error`. This will cause the build to
+    // fail if the JDK version between compileKotlin and compileJava and jvmTarget are not
+    // aligned. This won't be necessary anymore from React Native 0.73. More on this:
+    // https://kotlinlang.org/docs/whatsnew18.html#obligatory-check-for-jvm-targets-of-related-kotlin-and-java-compile-tasks
+    input.rootProject.extensions.extraProperties.set("kotlin.jvm.target.validation.mode", "warning")
   }
 }
darthgween commented 4 months ago

Hi! Despite @fadi-quader-mox solution works for me and it build everything correctly if you want to use react-navigation it works properly in the app module but the appInstant module will crash, i checked and it seems to be related to the navigation, e.g. I putted in App.tsx this code: return (

Any suggestions to let it work?

ko-devHong commented 2 months ago

i patched @react-native/gradle-plugin/src/main/kotlin/com/facebook/react/utils/JdkConfiguratorUtils.kt with the one in React Native 0.72.9 and it worked

diff --git a/node_modules/@react-native/gradle-plugin/src/main/kotlin/com/facebook/react/utils/JdkConfiguratorUtils.kt b/node_modules/@react-native/gradle-plugin/src/main/kotlin/com/facebook/react/utils/JdkConfiguratorUtils.kt
index 0d55714..e79f0e9 100644
--- a/node_modules/@react-native/gradle-plugin/src/main/kotlin/com/facebook/react/utils/JdkConfiguratorUtils.kt
+++ b/node_modules/@react-native/gradle-plugin/src/main/kotlin/com/facebook/react/utils/JdkConfiguratorUtils.kt
@@ -15,6 +15,7 @@ import org.gradle.api.Project
 import org.gradle.api.plugins.AppliedPlugin
 import org.jetbrains.kotlin.gradle.dsl.KotlinTopLevelExtension

+// revert this file to RN 0.72 to fix https://github.com/facebook/react-native/issues/41580
 internal object JdkConfiguratorUtils {
   /**
    * Function that takes care of configuring the JDK toolchain for all the projects projects. As we
@@ -22,31 +23,26 @@ internal object JdkConfiguratorUtils {
    * configure the toolchain to 17.
    */
   fun configureJavaToolChains(input: Project) {
-    // Check at the app level if react.internal.disableJavaVersionAlignment is set.
     if (input.hasProperty(INTERNAL_DISABLE_JAVA_VERSION_ALIGNMENT)) {
       return
     }
     input.rootProject.allprojects { project ->
-      // Allows every single module to set react.internal.disableJavaVersionAlignment also.
-      if (project.hasProperty(INTERNAL_DISABLE_JAVA_VERSION_ALIGNMENT)) {
-        return@allprojects
-      }
       val action =
           Action<AppliedPlugin> {
-            project.extensions.getByType(AndroidComponentsExtension::class.java).finalizeDsl { ext
-              ->
+            project.extensions.getByType(AndroidComponentsExtension::class.java).finalizeDsl {
+                ext ->
               ext.compileOptions.sourceCompatibility = JavaVersion.VERSION_17
               ext.compileOptions.targetCompatibility = JavaVersion.VERSION_17
             }
           }
       project.pluginManager.withPlugin("com.android.application", action)
       project.pluginManager.withPlugin("com.android.library", action)
-      project.pluginManager.withPlugin("org.jetbrains.kotlin.android") {
-        project.extensions.getByType(KotlinTopLevelExtension::class.java).jvmToolchain(17)
-      }
-      project.pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
-        project.extensions.getByType(KotlinTopLevelExtension::class.java).jvmToolchain(17)
-      }
     }
+    // We set kotlin.jvm.target.validation.mode=warning on the root projects, as for projects
+    // on Gradle 8+ and Kotlin 1.8+ this value is set to `error`. This will cause the build to
+    // fail if the JDK version between compileKotlin and compileJava and jvmTarget are not
+    // aligned. This won't be necessary anymore from React Native 0.73. More on this:
+    // https://kotlinlang.org/docs/whatsnew18.html#obligatory-check-for-jvm-targets-of-related-kotlin-and-java-compile-tasks
+    input.rootProject.extensions.extraProperties.set("kotlin.jvm.target.validation.mode", "warning")
   }
 }

it's works for my project. my RN version : 0.73.9