diff --git a/README.md b/README.md index 018267b9..693c321a 100644 --- a/README.md +++ b/README.md @@ -226,6 +226,10 @@ React Native Brownfield is an open source project and will always remain free to 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! 🔥 +## Troubleshooting + +For troubleshooting common issues, please refer to [TROUBLESHOOTING.md](docs/TROUBLESHOOTING.md). + ## Contributors Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)): diff --git a/docs/TROUBLESHOOTING.md b/docs/TROUBLESHOOTING.md new file mode 100644 index 00000000..4c2cc85b --- /dev/null +++ b/docs/TROUBLESHOOTING.md @@ -0,0 +1,9 @@ +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. + +## [Android] `Error: duplicate resources` during `:app:mergeReleaseAssets` + +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. + +## [iOS] `No script URL provided` in Release configuration + +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`. diff --git a/gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/plugin/RNSourceSets.kt b/gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/plugin/RNSourceSets.kt index 3eda0cd5..6f5ed274 100644 --- a/gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/plugin/RNSourceSets.kt +++ b/gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/plugin/RNSourceSets.kt @@ -44,10 +44,16 @@ object RNSourceSets { } private fun configureSourceSets() { - androidExtension.sourceSets.getByName("main") { - it.assets.srcDirs("$appBuildDir/generated/assets/createBundleReleaseJsAndAssets") - it.res.srcDirs("$appBuildDir/generated/res/createBundleReleaseJsAndAssets") - it.java.srcDirs("$moduleBuildDir/generated/autolinking/src/main/java") + androidExtension.sourceSets.getByName("main") { sourceSet -> + for (bundlePathSegment in listOf( + "createBundleReleaseJsAndAssets", // outputs for RN <= 0.81 + "react/release" // outputs for RN >= 0.82 + )) { + sourceSet.assets.srcDirs("${appBuildDir}/generated/assets/$bundlePathSegment") + sourceSet.res.srcDirs("$appBuildDir/generated/res/$bundlePathSegment") + } + + sourceSet.java.srcDirs("$moduleBuildDir/generated/autolinking/src/main/java") } androidExtension.sourceSets.getByName("release") {