Skip to content

Commit 8f717f8

Browse files
authored
chore: update assets & res srcDirs to match RN paths (#158)
1 parent d441747 commit 8f717f8

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,10 @@ React Native Brownfield is an open source project and will always remain free to
226226

227227
Like the project? ⚛️ [Join the team](https://callstack.com/careers/?utm_campaign=Senior_RN&utm_source=github&utm_medium=readme) who does amazing stuff for clients and drives React Native Open Source! 🔥
228228

229+
## Troubleshooting
230+
231+
For troubleshooting common issues, please refer to [TROUBLESHOOTING.md](docs/TROUBLESHOOTING.md).
232+
229233
## Contributors
230234

231235
Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):

docs/TROUBLESHOOTING.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
This section provides a troubleshooting guide for common issues encountered when using the `react-native-brownfield` library. If you face any problems not covered here, please refer to the official documentation or reach out to the community for support.
2+
3+
## [Android] `Error: duplicate resources` during `:app:mergeReleaseAssets`
4+
5+
An error like `Error: duplicate resources` during the `:app:mergeReleaseAssets` phase may occur if you have upgraded your React Native version from a version less than `0.82.0`, to a version greater than or equal to (>=) `0.82.0`. This is because RN 0.82.0 changed the path to which the JS bundle is written to from `build/generated/assets/createBundleReleaseJsAndAssets/` to `build/generated/assets/react/release/`, and analogously changed the path for `res/createBundleReleaseJsAndAssets/`. The brownfield Gradle plugin adds both directories to the source sets, potentially causing a conflict of artifacts. To fix this, just once clean your build directory (precisely, the `app/build/` directory) and rebuild the project. All subsequent builds should work fine.
6+
7+
## [iOS] `No script URL provided` in Release configuration
8+
9+
If you encounter this error, most likely you have missed a setup step and are missing `ReactNativeBrownfield.shared.bundle = ReactNativeBundle` before your call to `startReactNative`.

gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/plugin/RNSourceSets.kt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,16 @@ object RNSourceSets {
4444
}
4545

4646
private fun configureSourceSets() {
47-
androidExtension.sourceSets.getByName("main") {
48-
it.assets.srcDirs("$appBuildDir/generated/assets/createBundleReleaseJsAndAssets")
49-
it.res.srcDirs("$appBuildDir/generated/res/createBundleReleaseJsAndAssets")
50-
it.java.srcDirs("$moduleBuildDir/generated/autolinking/src/main/java")
47+
androidExtension.sourceSets.getByName("main") { sourceSet ->
48+
for (bundlePathSegment in listOf(
49+
"createBundleReleaseJsAndAssets", // outputs for RN <= 0.81
50+
"react/release" // outputs for RN >= 0.82
51+
)) {
52+
sourceSet.assets.srcDirs("${appBuildDir}/generated/assets/$bundlePathSegment")
53+
sourceSet.res.srcDirs("$appBuildDir/generated/res/$bundlePathSegment")
54+
}
55+
56+
sourceSet.java.srcDirs("$moduleBuildDir/generated/autolinking/src/main/java")
5157
}
5258

5359
androidExtension.sourceSets.getByName("release") {

0 commit comments

Comments
 (0)