-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure namespace is specified for all the 3rd party libraries (#41085)
Summary: As stated here react-native-community/discussions-and-proposals#671 React Native 0.73 will depend on Android Gradle Plugin (AGP) 8.x which requires all libraries to specify a namespace in their build.gradle file, even though this issue was raised many months ago, lots of libraries have not been updated and don't specify a `namespace` inside their build.gradle files ## Changelog: [ANDROID] [CHANGED] - Ensure namespace is specified for all the 3rd party libraries Pull Request resolved: #41085 Test Plan: Run RNGP tests and test building rn-tester after doing the following procedure 1. Remove `namespace "com.facebook.react"` from react-native/packages/react-native/ReactAndroid/build.gradle 2. Add `package="com.facebook.react"` to react-native/packages/react-native/ReactAndroid/src/main/AndroidManifest.xml 3. Build rn-tester Also tested this using [BareExpo](https://github.com/expo/expo/tree/main/apps/bare-expo) with AGP 8.1.1 and all libraries that were missing the `namespace` compiled correctly Reviewed By: cipolleschi Differential Revision: D50556667 Pulled By: cortinico fbshipit-source-id: 3d75ec0a8b82427ff0ede89aa7bc58b28b288945
- Loading branch information
1 parent
8809392
commit 13ae111
Showing
3 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/AgpConfiguratorUtilsTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* 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.utils | ||
|
||
import java.io.File | ||
import org.junit.Assert.* | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.rules.TemporaryFolder | ||
|
||
class AgpConfiguratorUtilsTest { | ||
|
||
@get:Rule val tempFolder = TemporaryFolder() | ||
|
||
@Test | ||
fun getPackageNameFromManifest_withEmptyFile_returnsNull() { | ||
val mainFolder = tempFolder.newFolder("awesome-module/src/main/") | ||
val manifest = File(mainFolder, "AndroidManifest.xml").apply { writeText("") } | ||
|
||
val actual = getPackageNameFromManifest(manifest) | ||
assertNull(actual) | ||
} | ||
|
||
@Test | ||
fun getPackageNameFromManifest_withMissingPackage_returnsNull() { | ||
val mainFolder = tempFolder.newFolder("awesome-module/src/main/") | ||
val manifest = | ||
File(mainFolder, "AndroidManifest.xml").apply { | ||
writeText( | ||
// language=xml | ||
""" | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
</manifest> | ||
""" | ||
.trimIndent()) | ||
} | ||
|
||
val actual = getPackageNameFromManifest(manifest) | ||
assertNull(actual) | ||
} | ||
|
||
@Test | ||
fun getPackageNameFromManifest_withPackage_returnsPackage() { | ||
val mainFolder = tempFolder.newFolder("awesome-module/src/main/") | ||
val manifest = | ||
File(mainFolder, "AndroidManifest.xml").apply { | ||
writeText( | ||
// language=xml | ||
""" | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.facebook.react" > | ||
</manifest> | ||
""" | ||
.trimIndent()) | ||
} | ||
|
||
val actual = getPackageNameFromManifest(manifest) | ||
assertNotNull(actual) | ||
assertEquals("com.facebook.react", actual) | ||
} | ||
} |