Repository: facebook/react-native (language: cpp)

Issue:
3rd party libraries with name starting with 'a' are breaking Android project evaluation
              This will not work if the 3rd party librariy's name is before the 'app', such as 'aliyun' .....,
How can I fix it? @gabrieldonadel ,@cortinico

_Originally posted by @liuzetan in https://github.com/facebook/react-native/issues/41085#issuecomment-1823894611_
            


Discussion / hints:
| :warning: | Missing Reproducible Example |
| --- | --- |
| :information_source: | We could not detect a reproducible example in your issue report. Please provide either: <br /><ul><li>If your bug is UI related: a [Snack](https://snack.expo.dev)</li><li> If your bug is build/update related: use our [Reproducer Template](https://github.com/react-native-community/reproducer-react-native/generate). A reproducer needs to be in a GitHub repository under your username.</li></ul> |

Fix patch:
diff --git a/packages/react-native-gradle-plugin/build.gradle.kts b/packages/react-native-gradle-plugin/build.gradle.kts
index c4a31beb010e19..9346508f497062 100644
--- a/packages/react-native-gradle-plugin/build.gradle.kts
+++ b/packages/react-native-gradle-plugin/build.gradle.kts
@@ -26,6 +26,10 @@ gradlePlugin {
       id = "com.facebook.react"
       implementationClass = "com.facebook.react.ReactPlugin"
     }
+    create("reactrootproject") {
+      id = "com.facebook.react.rootproject"
+      implementationClass = "com.facebook.react.ReactRootProjectPlugin"
+    }
   }
 }
 
diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactRootProjectPlugin.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactRootProjectPlugin.kt
new file mode 100644
index 00000000000000..5f232cd0e581a5
--- /dev/null
+++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactRootProjectPlugin.kt
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+
+package com.facebook.react
+
+import org.gradle.api.Plugin
+import org.gradle.api.Project
+
+/**
+ * Gradle plugin applied to the `android/build.gradle` file.
+ *
+ * This plugin allows to specify project wide configurations that can be applied to both apps and
+ * libraries before they're evaluated.
+ */
+class ReactRootProjectPlugin : Plugin<Project> {
+  override fun apply(project: Project) {
+    project.subprojects {
+      // As the :app project (i.e. ReactPlugin) configures both namespaces and JVM toolchains
+      // for libraries, its evaluation must happen before the libraries' evaluation.
+      // Eventually the configuration of namespace/JVM toolchain can be moved inside this plugin.
+      if (it.path != ":app") {
+        it.evaluationDependsOn(":app")
+      }
+    }
+  }
+}
diff --git a/packages/react-native/template/android/build.gradle b/packages/react-native/template/android/build.gradle
index 7e6117e3ab46d5..cb9d6232a7044e 100644
--- a/packages/react-native/template/android/build.gradle
+++ b/packages/react-native/template/android/build.gradle
@@ -1,5 +1,3 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
-
 buildscript {
     ext {
         buildToolsVersion = "34.0.0"
@@ -19,3 +17,5 @@ buildscript {
         classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
     }
 }
+
+apply plugin: "com.facebook.react.rootproject"


Test patch: