{"_id":"590a04f8ed80861900cbc7ac","user":"55b2d5626862a10d00887af9","category":{"_id":"590a04f3ed80861900cbc74c","__v":0,"version":"590a04f2ed80861900cbc737","project":"55b2d5baa74a380d00e290c4","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-01-05T19:32:59.974Z","from_sync":false,"order":22,"slug":"troubleshooting","title":"Troubleshooting"},"project":"55b2d5baa74a380d00e290c4","__v":0,"parentDoc":null,"version":{"_id":"590a04f2ed80861900cbc737","project":"55b2d5baa74a380d00e290c4","__v":4,"createdAt":"2017-05-03T16:27:30.085Z","releaseDate":"2017-05-03T16:27:30.085Z","categories":["590a04f3ed80861900cbc738","590a04f3ed80861900cbc739","590a04f3ed80861900cbc73a","590a04f3ed80861900cbc73b","590a04f3ed80861900cbc73c","590a04f3ed80861900cbc73d","590a04f3ed80861900cbc73e","590a04f3ed80861900cbc73f","590a04f3ed80861900cbc740","590a04f3ed80861900cbc741","590a04f3ed80861900cbc742","590a04f3ed80861900cbc743","590a04f3ed80861900cbc744","590a04f3ed80861900cbc745","590a04f3ed80861900cbc746","590a04f3ed80861900cbc747","590a04f3ed80861900cbc748","590a04f3ed80861900cbc749","590a04f3ed80861900cbc74a","590a04f3ed80861900cbc74b","590a04f3ed80861900cbc74c","590a04f3ed80861900cbc74d","59124949de13f61900336a7a","5914b04e7c2c552d008b7104","5914b47242c6a22300b9dc20"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"7.0.0","version":"7"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2017-01-18T18:36:44.472Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":4,"body":"We’ve put together a quick checklist to help teams troubleshoot the most common causes for build failures.\n\nHere's what you can to do quickly diagnose and likely resolve build errors:\n\n* Clone your repo and check if your app builds locally\n* Double check your third party dependencies\n* Make sure your app is configured to generate an offline bundle\n\n# Clone your repo and check if your app builds locally\n\nIt's important to make sure there are no discrepancies between your remote branch and local git state.\n\nBuddybuild creates a fresh clone of your code and executes build commands on every commit.\n\nHere's how to replicate this process and ensure your remote branch is up to date:\n- Clone your repo into a new location / folder on your machine\n- **Make sure that the node version installed on your machine is what's being used on buddybuild**\n- Do a fresh npm install and attempt to build your app\n\n# Double check your third party dependencies\n\n## Node\n* Make sure that the node version you are using locally is the same as what's being used to build the branch you're having issues with.\n* A frequently seen issue is a `package.json` that specifies non-explicit versions of package dependencies (i.e. using carats `^` and tildes `~`). This might result in failed builds because different versions of dependencies are being installed on buddybuild than what is being used on your local machine. Our recommendation is to either remove these characters or to move to using yarn, which has a corresponding yarn.lock that specifies the exact versions you're using locally.\n\n## Gradle\n* Bear in mind that even if you have your npm dependencies locked down, those npm dependencies might have gradle files that use wildcards to reference their dependencies. \nThose dependency versions are **NOT** locked down and might result in issues when building on Buddybuild.\nFor example:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"compile('com.facebook.android:facebook-android-sdk:4.+')\",\n      \"language\": \"groovy\",\n      \"name\": \"Wildcarded Dependency\"\n    }\n  ]\n}\n[/block]\n# Make sure your app is configured to generate an offline bundle \nAn offline bundle is required for CI systems to pack the relevant Javascript code into your app, as there's no development server around to share javascript code.\nFor Android, you will notice at the top of your app/build.gradle file a commented auto-generated block that indicates how to generate an offline bundle for a given variant. By default, offline bundles are disabled for debug/development variants.\nThe below provides an example as to how to generate an offline bundle for a debug variant.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"project.ext.react = [\\n        // whether to bundle JS and assets in staging mode\\n        bundleInDebug: true,\\n        jsBundleDirDebug: \\\"$buildDir/intermediates/assets/debug\\\"\\n]\\n\\napply from: \\\"../../node_modules/react-native/react.gradle\\\"\",\n      \"language\": \"groovy\"\n    }\n  ]\n}\n[/block]\n# Troubleshooting Errors\n\n## Unable to resolve module <modulename> from <path>: Module does not exist in the module map or in these directories:\nWe've found that this error is generally caused by using wildcards (^ or ~) in your package.json.\nOur recommendation is to either remove the wildcards, or to move to using yarn and committing your yarn.lock.\n\n## Could not get BatchedBridge, make sure your bundle is packaged properly\nThis indicates that your app is not correctly configured to generate offline bundles, which is required for apps generated using continuous integration systems like Buddybuild.\nLook to \"Make sure your app is configured to generate an offline bundle\" as to how to configure your app to resolve this.\n\n## error: package <name> does not exist\nThis is generally caused by two different issues.\n1. Your settings.gradle path references to react native modules might be invalid.\n2. You've upgraded to a buildToolsVersion that one of your react native dependencies does not support. For example, if you were to upgrade to buildToolsVersion 25.0.0, that mandates that all your application's dependencies must also be at least at that buildToolsVersion. If a dependency does not satisfy that requirement, gradle will silently ignore the dependency and you'll get import errors.\n\n##  error: 'FBSDKShareKit/FBSDKShareKit.h' file not found\nThis is generally a result of an incorrectly configured repository with regards to the location of FBSDK  dependencies.\nIf you take a look at:\nhttps://github.com/facebook/react-native-fbsdk/blob/master/ios/RCTFBSDK.xcodeproj/project.pbxproj\n\nYou will notice that RCTFBSDK will look for dependencies in one of two locations:\n* ~/Documents/FacebookSDK\n* $(PROJECT_DIR)/../../../ios/Frameworks\n\nThe second option is the correct option for continuous integration systems like Buddybuild.\nIn other words, you MUST place your FBSDK dependencies under the \"ios/Frameworks\" folder in order for it to work on a continuous integration system.\n\n## React Native packager is stalling during an Android build\nIf you're stuck at \"mergeReleaseResources\" or \"bundleReleaseJsAndAssets\", one reason we've found this to be case is that there are realm auxiliary artifacts lying around in one of your directories that the react native package is attempting to traverse/parse.\nIn particular \"default.realm.*\" files or a \"realm-object-server\" directory.\nMore often that not, we've found these artifacts to be generated by some test framework (i.e. jest).\nhttps://realm.io/docs/objc/latest/#auxiliary-realm-files\n\n## /node_modules/react-native-fbsdk/android/build/intermediates/res/merged/release/values-v24/values-v24.xml:3: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.\n\nThis generally is a result of version mismatches.\nreact-native-fbsdk node module uses wildcards in its gradle file to reference its facebook-android-sdk version dependency, and depending on the version picked up, it can cause failures.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"compile('com.facebook.android:facebook-android-sdk:4.+')\",\n      \"language\": \"groovy\"\n    }\n  ]\n}\n[/block]\nThe below stack overflow article explains the issue and resolutions in more detail:\nhttps://stackoverflow.com/questions/44190829/facebook-sdk-android-error-building","excerpt":"","slug":"common-react-native-errors","type":"basic","title":"Common React Native errors"}

Common React Native errors


We’ve put together a quick checklist to help teams troubleshoot the most common causes for build failures. Here's what you can to do quickly diagnose and likely resolve build errors: * Clone your repo and check if your app builds locally * Double check your third party dependencies * Make sure your app is configured to generate an offline bundle # Clone your repo and check if your app builds locally It's important to make sure there are no discrepancies between your remote branch and local git state. Buddybuild creates a fresh clone of your code and executes build commands on every commit. Here's how to replicate this process and ensure your remote branch is up to date: - Clone your repo into a new location / folder on your machine - **Make sure that the node version installed on your machine is what's being used on buddybuild** - Do a fresh npm install and attempt to build your app # Double check your third party dependencies ## Node * Make sure that the node version you are using locally is the same as what's being used to build the branch you're having issues with. * A frequently seen issue is a `package.json` that specifies non-explicit versions of package dependencies (i.e. using carats `^` and tildes `~`). This might result in failed builds because different versions of dependencies are being installed on buddybuild than what is being used on your local machine. Our recommendation is to either remove these characters or to move to using yarn, which has a corresponding yarn.lock that specifies the exact versions you're using locally. ## Gradle * Bear in mind that even if you have your npm dependencies locked down, those npm dependencies might have gradle files that use wildcards to reference their dependencies. Those dependency versions are **NOT** locked down and might result in issues when building on Buddybuild. For example: [block:code] { "codes": [ { "code": "compile('com.facebook.android:facebook-android-sdk:4.+')", "language": "groovy", "name": "Wildcarded Dependency" } ] } [/block] # Make sure your app is configured to generate an offline bundle An offline bundle is required for CI systems to pack the relevant Javascript code into your app, as there's no development server around to share javascript code. For Android, you will notice at the top of your app/build.gradle file a commented auto-generated block that indicates how to generate an offline bundle for a given variant. By default, offline bundles are disabled for debug/development variants. The below provides an example as to how to generate an offline bundle for a debug variant. [block:code] { "codes": [ { "code": "project.ext.react = [\n // whether to bundle JS and assets in staging mode\n bundleInDebug: true,\n jsBundleDirDebug: \"$buildDir/intermediates/assets/debug\"\n]\n\napply from: \"../../node_modules/react-native/react.gradle\"", "language": "groovy" } ] } [/block] # Troubleshooting Errors ## Unable to resolve module <modulename> from <path>: Module does not exist in the module map or in these directories: We've found that this error is generally caused by using wildcards (^ or ~) in your package.json. Our recommendation is to either remove the wildcards, or to move to using yarn and committing your yarn.lock. ## Could not get BatchedBridge, make sure your bundle is packaged properly This indicates that your app is not correctly configured to generate offline bundles, which is required for apps generated using continuous integration systems like Buddybuild. Look to "Make sure your app is configured to generate an offline bundle" as to how to configure your app to resolve this. ## error: package <name> does not exist This is generally caused by two different issues. 1. Your settings.gradle path references to react native modules might be invalid. 2. You've upgraded to a buildToolsVersion that one of your react native dependencies does not support. For example, if you were to upgrade to buildToolsVersion 25.0.0, that mandates that all your application's dependencies must also be at least at that buildToolsVersion. If a dependency does not satisfy that requirement, gradle will silently ignore the dependency and you'll get import errors. ## error: 'FBSDKShareKit/FBSDKShareKit.h' file not found This is generally a result of an incorrectly configured repository with regards to the location of FBSDK dependencies. If you take a look at: https://github.com/facebook/react-native-fbsdk/blob/master/ios/RCTFBSDK.xcodeproj/project.pbxproj You will notice that RCTFBSDK will look for dependencies in one of two locations: * ~/Documents/FacebookSDK * $(PROJECT_DIR)/../../../ios/Frameworks The second option is the correct option for continuous integration systems like Buddybuild. In other words, you MUST place your FBSDK dependencies under the "ios/Frameworks" folder in order for it to work on a continuous integration system. ## React Native packager is stalling during an Android build If you're stuck at "mergeReleaseResources" or "bundleReleaseJsAndAssets", one reason we've found this to be case is that there are realm auxiliary artifacts lying around in one of your directories that the react native package is attempting to traverse/parse. In particular "default.realm.*" files or a "realm-object-server" directory. More often that not, we've found these artifacts to be generated by some test framework (i.e. jest). https://realm.io/docs/objc/latest/#auxiliary-realm-files ## /node_modules/react-native-fbsdk/android/build/intermediates/res/merged/release/values-v24/values-v24.xml:3: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'. This generally is a result of version mismatches. react-native-fbsdk node module uses wildcards in its gradle file to reference its facebook-android-sdk version dependency, and depending on the version picked up, it can cause failures. [block:code] { "codes": [ { "code": "compile('com.facebook.android:facebook-android-sdk:4.+')", "language": "groovy" } ] } [/block] The below stack overflow article explains the issue and resolutions in more detail: https://stackoverflow.com/questions/44190829/facebook-sdk-android-error-building