Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26037] Hyperloop: Accessing internal WebSocket library

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionInvalid
Resolution Date2019-07-30T01:09:12.000+0000
Affected Version/sRelease 7.1.1
Fix Version/sn/a
Componentsn/a
Labelsandroid, engTriage, hyperloop, websocket
ReporterMichael Gangolf
AssigneeJoshua Quick
Created2018-05-08T17:02:01.000+0000
Updated2020-03-19T00:52:19.000+0000

Description

Titanium is shipping a java_websocket.jar in /linux/7.1.1.GA/android/ which I can use in a normal Android module by just importing it with import org.java_websocket.client.WebSocketClient;. No need to put the jar into my project folder. When trying the same with Hyperloop I always get the error, that the module is not found. When placing the jar into the project folder it complains about duplicate classes. Is there a way to access the libraries inside the Android folder using Hyperloop? Titanium SDK 7.1.1.GA

Comments

  1. Alan Hutton 2019-07-02

    Devs can use our "titanium-socketio" module for websocket support. https://github.com/appcelerator-modules/titanium-socketio
  2. Michael Gangolf 2019-07-02

    [~ahutton] we've tried to connect to a Websocket server (not a socket.io server!) with the Socketio module today and weren't able to do that because of xhr poll errors. I didn't try it but I guess the same error as in the description would appear for other modules inside the SDKs library folder (so you can't use exifinterface.jar or a support library in HL?)
  3. Joshua Quick 2019-07-25

    [~michael], hyperloop currently does not support referencing Titanium's core JARs and the JARs it directly includes. It's not part of hyperloop's lookup path. And adding the WebSocket JAR to your "modules" directory will cause a build failure due to Java class collision (renaming the JAR file won't solve this). I think your only option is to make a native module and leverage the WebSocket JAR that Titanium already includes. Ideally, hyperloop should be changed to lookup Titanium's core JARs as well. I don't think there is any technical reason why this limitation should exist. But I don't see us doing this in the near future though. Side Note: Titanium uses web sockets for debugging.
  4. Joshua Quick 2019-07-25

    Alternatively, you can use a command line tool to change the package names of all Java classes within the WebSocket JAR and include that in your "modules" directory. That would work, but it's kind of a slimy hack. https://stackoverflow.com/questions/13746737/hand-edit-a-jar-to-change-package-names That said, Google has a tool that transitions JARs from the old Google Support libraries to the new AndroidX libraries. For example, their tool change references from android.support.v7.app.AppCompatActivity to androidx.appcompat.app.AppCompatActivity. So, Google sanctions hacks like this. Not quite the same for what I'm suggesting above, but if you need any justification, here it is. :P https://developer.android.com/jetpack/androidx/migrate
  5. Michael Gangolf 2019-07-25

    Thanks [~jquick] for all the details! I think the module will be the easiest way :)
  6. Joshua Quick 2019-07-30

    [~michael], I wrote this up as a feature request here: [TIMOB-27297]
  7. Joshua Quick 2020-03-19

    [~michael], as of Titanium 9.0.0 you can do this now. I recommend that you copy our "titanium.socketio" module's "build.gradle" via the link below and copy it to your project's ./platform/android directory. https://github.com/appcelerator-modules/titanium-socketio/blob/master/android/build.gradle This will allow hyperloop to access the Java classes you see in the below repo. https://github.com/socketio/socket.io-client-java

JSON Source