react-native-socketio icon indicating copy to clipboard operation
react-native-socketio copied to clipboard

Compile failed with React Native 0.32

Open orange-beans opened this issue 8 years ago • 6 comments

Compile failed with the following message when I tried to build for Android :

Project_Path\node_modules\react-native-socketio\android\src\mai n\java\com\gcrabtree\rctsocketio\SocketIoReadableNativeMap.java:16: error: constru ctor ReadableNativeMap in class ReadableNativeMap cannot be applied to given types ; public class SocketIoReadableNativeMap extends ReadableNativeMap { ^ required: HybridData found: no arguments reason: actual and formal argument lists differ in length 1 error :SocketIo:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':SocketIo:compileDebugJavaWithJavac'.

    Compilation failed; see the compiler error output for details.

React Native Version: 0.32 Operating system: Win 7

orange-beans avatar Sep 11 '16 11:09 orange-beans

you can add the default constructer by yourself

pj0579 avatar Sep 12 '16 10:09 pj0579

I get same error. @pj0579 Please tell me which variable i need to declare in default constructor.

mvnnn avatar Sep 22 '16 05:09 mvnnn

@orange-beans You get the solution of this error.

mvnnn avatar Sep 23 '16 12:09 mvnnn

@mvnnn Nope, I will wait until the problem is solved by the author. Currently I'm implementing socket.io-client directly, which is working no problem in Android, but got reception problem in iOS, suspect to be permission issue.

Following code for your reference.

SocketUtil.js

window.navigator.userAgent = 'react-native';
const io = require('socket.io-client/socket.io');
export const socket = io('http://127.0.0.1:80', {
  transports: ['websocket'], // you need to explicitly tell it to use websockets
});
export default io;

App.js

// Your Import
// ...
import { socket } from './SocketUtil';
import io from './SocketUtil';
// Use preset socket
socket.on('connect', () => {
  console.warn('connected!');
  socket.emit('hello', 'socket connected');
});
// Create new socket
const mySocket = io('http://XXX.XXX.XXX.XXX:80', {
  transports: ['websocket'],
});
mySocket.on('connect', () => {
  console.warn('connected!');
  socket.emit('hello', 'a different connection');
});
// Your Code
// ...

orange-beans avatar Sep 26 '16 05:09 orange-beans

@orange-beans A bit unrelated, but what is the difference between using socket.io-client with React Native Websockets instead of this react-native-socketio module?

And do you know if socket.io-client supports HTTPS? Related: https://medium.com/@daywong/how-about-https-aff36566da38#.sqcmsehjz

davidperrenoud avatar Sep 26 '16 08:09 davidperrenoud

@orange-beans @mvnnn add "protected SocketIoReadableNativeMap(HybridData hybridData) { super(hybridData) }" to NativeMap.java or use socket.io-client it's working no problem in Android and Ios ,i have try it

pj0579 avatar Sep 27 '16 06:09 pj0579