Skip to content

Instantly share code, notes, and snippets.

@mjonesjr90
Last active September 12, 2018 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjonesjr90/7bc894abe2994383d512b306360b9822 to your computer and use it in GitHub Desktop.
Save mjonesjr90/7bc894abe2994383d512b306360b9822 to your computer and use it in GitHub Desktop.
Documenting small issues I run into while tinkering with React Native

ISSUE

Modifying my native module (Android code) I would see the following error when trying to compile my app

Execution failed for task ':react-native-[package-name]:compileReleaseJavaWithJavac'. 
Unable to find source java class […] because it does not belong to any of the source dirs: […]

FIX

Clean gradle within the app Android folder

cd [Project-Folder]/android
./gradlew clean
cd ..
react-native run-android

ISSUE

A problem occurred configuring project ':app'.
> The SDK Build Tools revision (23.0.3) is too low for project ':app'. Minimum required is 25.0.0

FIX

Ensure buildToolsVersion is at a matching API level to the compileSdkVersion in build.gradle of your app


ISSUE

error: bundling failed: Error: Unable to resolve module `[YOUR_MODULE]`: Module `[YOUR_MODULE]` does not exist in the Haste module map

FIX

The fix is listed in the error as follows

This might be related to https://github.com/facebook/react-native/issues/4968
To resolve try the following:
  1. Clear watchman watches: `watchman watch-del-all`.
  2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
  3. Reset Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`.  
  4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`.

ISSUE

error: bundling failed: Error: ENOENT: no such file or directory, uv_cwd [...]

FIX

Metro Bundler, the JS bundler for React Native uses port 8081. Sometimes a process won't release it so you can reboot or killall


ISSUE

Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/reactlibrary/BuildConfig;

FIX

The package name in the Android Manifest of each of your modules must be different.


ISSUE After compiling the app, the device shows a red screen with the following

Native module [MODULE_NAME] tried to override [MODULE_NAME] for module name [MODULE_NAME]. If this was your intention, set canOverrideExistingModule=true

FIX

Make sure the module/package in question is not listed twice in the getPackages() method within your MainApplication.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment