Troubleshooting React Native Gesture Handler Compilation Error in Android APK Build
Introduction
When building an Android APK for a React Native project, you may encounter compilation errors related to the react-native-gesture-handler library. This error is often a result of version mismatches or configuration issues within the project setup. In this article, we will explore common solutions to resolve the React Native Gesture Handler compilation error.
Error Description:
Task :react-native-gesture-handler:compileReleaseKotlin FAILED
e: /Users/saumya/Desktop/latest/lc-app/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt: (247, 92): Unresolved reference: TIRAMISU
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-gesture-handler:compileReleaseKotlin'.
> Compilation error. See log for more details
Solution Approaches:
1. Update Android SDK Versions
buildscript {
ext {
targetSdkVersion '33.0.0'
buildToolsVersion = 33
compileSdkVersion = 33
}
}
2. Check for Version Mismatches
If the error persists, consider updating the entire project to resolve any package version conflicts. Downgrading to react-native-gesture-handler version 2.8.0 might alleviate the issue:
yarn add [email protected]
3. Modify Build.Version Codes
Changing the Build.Version Codes could potentially resolve the compilation error:
Build.VERSION_CODES.TIRAMISU
Build.VERSION_CODES.LOLLIPOP
4. Specific Library Version
If the issue is caused by react-native-gesture-handler itself, try using a specific version like:
"react-native-gesture-handler": "2.9.0"
5. Additional SDK Configuration
ndkVersion = "25.0.8775105"
buildscript {
ext {
targetSdkVersion '33.0.0'
buildToolsVersion = 33
compileSdkVersion = 33
}
}
Conclusion
Resolving compilation errors in React Native Android APK builds, especially related to react-native-gesture-handler, requires careful version management and configuration adjustments. By following the steps outlined above, you can troubleshoot and overcome common issues encountered during the build process.