@@ -9,7 +9,6 @@ package com.facebook.react.utils
99
1010import com.android.build.api.variant.ApplicationAndroidComponentsExtension
1111import com.android.build.api.variant.LibraryAndroidComponentsExtension
12- import com.android.build.gradle.LibraryExtension
1312import com.facebook.react.ReactExtension
1413import com.facebook.react.utils.ProjectUtils.isEdgeToEdgeEnabled
1514import com.facebook.react.utils.ProjectUtils.isHermesEnabled
@@ -18,7 +17,6 @@ import java.net.Inet4Address
1817import java.net.NetworkInterface
1918import javax.xml.parsers.DocumentBuilder
2019import javax.xml.parsers.DocumentBuilderFactory
21- import kotlin.plus
2220import org.gradle.api.Action
2321import org.gradle.api.Project
2422import org.gradle.api.plugins.AppliedPlugin
@@ -77,14 +75,12 @@ internal object AgpConfiguratorUtils {
7775 project.pluginManager.withPlugin(" com.android.library" , action)
7876 }
7977
80- fun configureBuildConfigFieldsForLibraries (appProject : Project ) {
81- appProject.rootProject.allprojects { subproject ->
82- subproject.pluginManager.withPlugin(" com.android.library" ) {
83- subproject.extensions
84- .getByType(LibraryAndroidComponentsExtension ::class .java)
85- .finalizeDsl { ext -> ext.buildFeatures.buildConfig = true }
78+ fun configureBuildConfigFieldsForLibraries (project : Project ) {
79+ project.extensions
80+ .getByType(LibraryAndroidComponentsExtension ::class .java)
81+ .finalizeDsl { ext ->
82+ ext.buildFeatures.buildConfig = true
8683 }
87- }
8884 }
8985
9086 fun configureDevServerLocation (project : Project ) {
@@ -111,27 +107,22 @@ internal object AgpConfiguratorUtils {
111107 project.pluginManager.withPlugin(" com.android.library" , action)
112108 }
113109
114- fun configureNamespaceForLibraries (appProject : Project ) {
115- appProject.rootProject.allprojects { subproject ->
116- subproject.pluginManager.withPlugin(" com.android.library" ) {
117- subproject.extensions
118- .getByType(LibraryAndroidComponentsExtension ::class .java)
119- .finalizeDsl { ext ->
120- if (ext.namespace == null ) {
121- val android = subproject.extensions.getByType(LibraryExtension ::class .java)
122- val manifestFile = android.sourceSets.getByName(" main" ).manifest.srcFile
123-
124- manifestFile
125- .takeIf { it.exists() }
126- ?.let { file ->
127- getPackageNameFromManifest(file)?.let { packageName ->
128- ext.namespace = packageName
129- }
130- }
110+ fun configureNamespaceForLibraries (project : Project ) {
111+ project.extensions
112+ .getByType(LibraryAndroidComponentsExtension ::class .java)
113+ .finalizeDsl { ext ->
114+ if (ext.namespace == null ) {
115+ val manifestFile =
116+ project.layout.projectDirectory.file(" src/main/AndroidManifest.xml" ).asFile
117+ manifestFile
118+ .takeIf { it.exists() }
119+ ?.let { file ->
120+ getPackageNameFromManifest(file)?.let { packageName ->
121+ ext.namespace = packageName
131122 }
132123 }
124+ }
133125 }
134- }
135126 }
136127}
137128
0 commit comments