I use signalR lib in my project. but I was not able to compile libs of https://github.com/SignalR/java-client on my own - I found them in internet. But it seems like there are not full (WebsocketTransport is missing)
When I compile https://github.com/SignalR/java-client, i get two libs, and paste them to my app.gradle -
compile files ('libs/signalr-client-sdk.jar')
compile files ('libs/signalr-client-sdk-android.jar')
Progects build suckesfully, butwhen I press run - it fails. Here is stack trace -
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472)
at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
at com.android.dx.command.dexer.Main.processClass(Main.java:704)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
at com.android.dx.command.dexer.Main.access$300(Main.java:83)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:632)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:280)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
...while parsing microsoft/aspnet/signalr/client/Action.class
1 error; aborting Error:Execution failed for task ':app:preDexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_45\bin\java.exe'' finished with non-zero exit value 1
I do not know what to do. I even tried to compile forks of this project, but have got the same result, same error. Need any help, Thanks!
UPDATE
in my Application class i have
Platform.loadPlatformComponent(new AndroidPlatformComponent());
in my app.gradle:
compile files ('libs/gson-2.2.2.jar')
compile files ('libs/signalr-client-sdk.jar')
compile files ('libs/signalr-client-sdk-android.jar')
in my code I use
connection.start(new ServerSentEventsTransport(connection.getLogger())).get();
I also create lots of hubs on this connection, nad call methods. All works, but connection always dissapears, if i do not do anything with device more then for 30 seconds. And I do not have any callbacks that the connection was lost\disconected or anything like that - I log all this stuff. But I think it can happen because i have pretty old libs, i googled - as I mention in this question i did not menaged to build signalR project to receive more recent libs
JUST TO HELP SOMEONE WHO GOT STUCK LIKE ME.
I was trying to get my SingalR to work. I followed the answer given but service was not firing. This was my first project to implement a service like SignalRService. So I did not know.
I added
<service>
entry to my manifest file then everything started working.Thanks a lot BNK
Here is my working basic code, hope this helps!
Activity:
CustomMessage Class: