gcrabtree/react-native-socketio

Compile failed with React Native 0.32

Opened this issue · 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

you can add the default constructer by yourself

mvnnn commented

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

mvnnn commented

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

@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 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

@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