diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt index ce674463102..728edf88797 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt @@ -260,7 +260,9 @@ class ReactPlugin : Plugin { project.tasks.named("preBuild", Task::class.java).dependsOn(generatePackageListTask) // We tell Android Gradle Plugin that inside /build/generated/autolinking/src/main/java there - // are sources to be compiled as well. + // are sources to be compiled as well. We only compile this code if project is not a library. + // Without this, the compiler will link the generated files to each of the library including + // the ones from OSS, which is not expected. if (!isLibrary) { project.extensions.getByType(AndroidComponentsExtension::class.java).apply { onVariants(selector().all()) { variant ->