react-native-drax: Library not working on Android Emulator
Hi everyone,
first of all I need to tell u that I am beginner with ReactNative, so if at the end this resolves as something stupid, forgive me.
I have created new app using the command:
npx react-native init puzzleNative for the application I want to build.
My Gradle version is:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
My package.json looks like this:
"name": "puzzleNative",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.36",
"@fortawesome/free-solid-svg-icons": "^5.15.4",
"@fortawesome/react-native-fontawesome": "^0.2.7",
"@reduxjs/toolkit": "^1.7.1",
"animate.css": "^4.1.1",
"react": "17.0.2",
"react-native": "0.67.2",
"react-native-drax": "^0.9.3",
"react-native-gesture-handler": "^2.2.0",
"react-redux": "^7.2.6",
"redux": "^4.1.2"
},
"devDependencies": {
"@babel/core": "^7.17.2",
"@babel/runtime": "^7.17.2",
"@react-native-community/eslint-config": "^3.0.1",
"babel-jest": "^27.5.1",
"eslint": "^8.9.0",
"jest": "^27.5.1",
"metro-react-native-babel-preset": "^0.68.0",
"react-test-renderer": "17.0.2"
},
"jest": {
"preset": "react-native"
}
}
And in the App.js file I am just trying to run the example from the github page like so:
import React from 'react';
import { StyleSheet, View } from 'react-native';
import { DraxProvider, DraxView } from 'react-native-drax';
export default function App() {
return (
<DraxProvider>
<View style={styles.container}>
<DraxView
style={styles.draggable}
onDragStart={() => {
console.log('start drag');
}}
payload="world"
/>
<DraxView
style={styles.receiver}
onReceiveDragEnter={({ dragged: { payload } }) => {
console.log(`hello ${payload}`);
}}
onReceiveDragExit={({ dragged: { payload } }) => {
console.log(`goodbye ${payload}`);
}}
onReceiveDragDrop={({ dragged: { payload } }) => {
console.log(`received ${payload}`);
}}
/>
</View>
</DraxProvider>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
draggable: {
width: 100,
height: 100,
backgroundColor: 'blue',
},
receiver: {
width: 100,
height: 100,
backgroundColor: 'green',
},
});
I am using Android 10 Q for my emulator.

Please if someone can help me I would really appreciate it.
Thanks in advance! đ
And I canât drag the bluebox. I dont have any errors in the console.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 15 (6 by maintainers)
@Arkan4ik. I kind of built my own system on top of
react-native-gesture-handler. It really wasnât that hard. If youâre interested in see it, itâs in mychess-two-waysrepo which is public. Itâs inapps/chess-rn/src/app/chessboard/ChessDnD.tsxObviously, in the domain is chess, with an 8x8 matrix, the problem of hit-testing is greatly simplified. But one could easily keep a map of draggables / droppables and do oneâs own. Thatâs basically what Drax and other similar systems do.https://stackoverflow.com/questions/71618989/react-native-gesture-handler-not-working-on-android.
This fix worked for me to get your color drag example working, @lafiosca . (by just grabbing and slightly modifying the component in âscreensâ, removing DragProvider from the component etc)>
But when I tried it in another app (with literally the identical hierarchy), it wouldnât work. I would get a warning in the snackbar in emulator: âref.measureLayout must be called with a ref from a Viewâ⌠looking at your code I saw the setting of that ref in the DraxView to be whatâs breaking. I literally have no idea why it works in one harness and not another.
I tired downgrade to 1.8 of react-native-gesture-handler handler, but gradle choked on it during the build.
dunno. frustrated.
Having same issue with Android emulator and ``react-native-gesture-handler": â^2.4.2â. Think this needs to be addressed as it doesnât seem to like the new versions of
react-native-gesture-handler. It will only be a problem going forward for Android.Hello @djordje47! I apologize that I will likely not have time to try to look into this and reproduce it myself, but I am curious about your screenshot. At the bottom it shows a yellow box dev warning from react-native-gesture-handler. Drax is built on top of react-native-gesture-handler, so if something is misconfigured about that, it will not work. Can you look into what that warning is and see if it helps you out?