Sometimes, various errors may occur when building an application, especially if you have updated plugins versions or made major changes in the application code or projects' build configuration.
Common error: compileDebugJavaWithJavac
.
Important note:
- Consider backing up of your project before performing any major cleanup or deletion operations to prevent potential data loss due to mistakes or errors.
- Be very careful with any
rm -rf
command, since it removes files recursively. Run it only inside the project directory. - Remember to close your IDE (e.g., Android Studio, VS Code) before running these commands, as they might interfere with the IDE's processes.
Table of contents:
React Native
Clearing the caches of Watchman, Metro Bundler and NPM in React Native project. This may require a few steps, depending on what additional tools you are using.
Clear the Metro Bundler cache
Clear the Metro Bundler cache. Run the following command from the root directory of your React Native project:
npx react-native start --reset-cache
Clear Watchman
Sometimes, resetting Watchman can help resolve issues related to file watching and detecting changes in a React Native project.
Open your terminal and navigate to your project directory and run the following command:
npx watchman watch-del-all
This removes all files and directories currently watched by the watchman daemon.
Optional. Reset Watchman with the server reload. Sometimes this may resolve rare issues.
# Remove all watches and stop the Watchman server
watchman watch-del-all && watchman shutdown-server
# Start the server again
watchman -v
Clear React Native cache
1. Delete cache directories:
# React Native < 0.50 and/or NPM >= 5.0
rm -rf $TMPDIR/react-*
# React Native >= 0.50
rm -rf $TMPDIR/react-native-packager-cache-*
rm -rf $TMPDIR/metro-bundler-cache-*
2. NPM cache clean:
# NPM cache clean
npm cache clean --force
# Verify that the cache has been successfully cleared
npm cache verify
3. Delete node_modules folder and reinstall dependencies:
# Delete node_modules directory
rm -rf node_modules
# Reinstall dependencies
npm install
# Start the packager with reset cache
npm start -- --reset-cache
Optional. Update the iOS pod
Execute cd ios && pod install && cd ..
or pod repo update && pod update
in your terminal in the project's directory.
Flutter
Cleaning cache and artifacts in a Flutter project can be useful for resolving issues like outdated dependencies and conflicting package versions.
Here are the steps to clean cache and artifacts in a Flutter project:
Basic:
# Clear the Flutter SDK's cache.
# It will delete the .dart_tool/ and build/ directories in your project
flutter clean
# Clean the pub cache
# It will remove all packages from the Flutter pub cache
# that aren't required by your project
flutter pub cache clean
Clean the Gradle cache (for the Android platform).
This process cleans the Android Gradle cache, the Flutter pub cache, and then re-fetches and reinstalls all the packages. The double flutter clean
commands ensure a thorough cleanup and reset.
flutter clean
flutter pub cache clean
flutter clean
flutter packages get
flutter pub get
After cleaning, you might need to rebuild your project with flutter run
or flutter build
.
Unity
Clear Temporary Cache Files
- Make sure your Unity editor is closed.
- Navigate to Your Project Folder (folder where your Unity project is located).
- Locate and delete the Library folder. Unity will regenerate this folder when you open the project again, but it may take some time as it rebuilds all the necessary files.
Clear Asset Store Cache
- Launch Unity.
- Open the Asset Store (Window → Asset Store).
- In the Asset Store window, click on the account icon and then select Download Manager.
- There should be an option to clear the cache.
Reimport All Assets
Sometimes, reimporting all assets can help clear out any lingering issues.
- Start your Unity project.
- In the Project window, select all your assets.
- Right-click and choose Reimport. This will force Unity to re-import all assets, potentially fixing any import-related issues.
Remove Invalid Dependencies
Via the Package Manager
- Start your Unity project.
- Open Package Manager (Window → Package Manager).
- Look for any packages marked with errors or warnings.
- Select the problematic package and either remove it or update it to the latest version.
Manual Cleanup
If you have dependencies that are not correctly referenced or are outdated, you might need to manually edit some files:
- Open
Packages/manifest.json
This file lists all the dependencies for your project. - Remove or correct any invalid dependencies. Ensure that the version numbers are correct, and the packages are still available in the Unity registry.
Clean the project
Android
1. Ensure that you have the latest supported version of the Android Gradle and Gradle Wrapper. Update them if needed.
2. Clean the Project. Run the following command in the project directory:
./gradlew clean
3. Invalidate caches and restart Android Studio. Go to File > Invalidate Caches / Restart
and click on Invalidate and Restart
.
Additional info:
- Ensure your project's configured Java version matches your system's installed version. Use
java -version
to check both. - Verify that all project dependencies are installed and correctly referenced in your
build.gradle
file. You can usenpx react-native run-android --variant=debug
to identify missing dependencies. - Update any third-party plugins to their latest versions and check for known compatibility issues with your React Native version.
- Ensure you have the latest Gradle version configured and are not using deprecated features.
Comments
0 comments
Please sign in to leave a comment.