Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: is it possible to use rsocket-java on Android as the client? #375

Closed
NexZhu opened this issue Aug 16, 2017 · 25 comments
Closed

Question: is it possible to use rsocket-java on Android as the client? #375

NexZhu opened this issue Aug 16, 2017 · 25 comments
Assignees

Comments

@NexZhu
Copy link

NexZhu commented Aug 16, 2017

What are the dependencies of the client part of rsocket-java?
Is it possible to use rsocket-java on Android?
Or maybe rsocket-cpp?
Thanks.

@lexs
Copy link
Contributor

lexs commented Aug 16, 2017

We (Facebook) use rsocket-cpp on Android and iOS talking to rsocket-cpp on the server.

rsocket-java should work (netty seems to work) but I don't think it's been tried before so might be some friction.

@NexZhu
Copy link
Author

NexZhu commented Aug 16, 2017

@lexs Sounds cool, I think I'll try rsocket-cpp. Thanks.

@NexZhu NexZhu closed this as completed Aug 16, 2017
@yschimke
Copy link
Member

@NexZhu I expect if you get rsocket-java working with Netty dependencies it will be simpler and good enough. You will also get a very strong reactive-streams based library with a lot of operators.

I can try to confirm it works on Android in the next week. Is that timeframe suitable?

This will save you tackling JNI and build issues. That said if you know JNI well, then the rsocket-cpp should be a fairly light dependency to add so it is a very viable option that we know works.

Which backends are you considering?

@yschimke yschimke reopened this Aug 16, 2017
@NexZhu
Copy link
Author

NexZhu commented Aug 18, 2017

@yschimke Sorry for the late response. As you said, it'd be very helpful if I could just use rsocket-java on Android. And I definitely want the reactive-streams based library. Plus, I'm not familiar with JNI either.

If you can give me some advice on what should I do to use it on Android, I can wait until next week, thanks!

Backend will be Java based using rsocket-java, I'm considering rx-netty/reactor.

@yschimke
Copy link
Member

If you use TCP or Websocket connectors it builds upon https://github.com/reactor/reactor-netty

The issue with Android support is going to be Java 8 support. It's either going to be a use Android Studio 3 (prerelease) with new compiler toolchains etc, or RetroLambda which would be min Android SDK 22 IIUC. But I'll let you know when I've got it working and submit a sample project that hits the public demo server at http://rsocket-demo.herokuapp.com/

@yschimke
Copy link
Member

yschimke commented Aug 19, 2017

I looked at both RetroLambda, before switching to Android Studio 3 pre-release which has more real support for Java 8.

https://developer.android.com/studio/write/java8-support.html

If Android Studio detects that your project is using Jack, Retrolambda, or DexGuard, the IDE uses Java 8 support provided by those tools instead. However, compared to the default toolchain, those tools lack some functionality and support. So follow the instructions in this section to migrate to Android Studio's default toolchain.

The awkward answer is that it works awesomely on Android O (26), but I think with a minor API change (avoiding requiring java.time) I can get it working cleanly for 24+. But that is a very small part of the market, so more relevant for an internal app than making your millions on the App Store.

rsocket-cpp will be the best bet for support < SDK 24.

@yschimke
Copy link
Member

I have no current plans to actually get it working on SDK 24, apart from raising an issue with Reactor asking about their status. Unless they commit to SDK 24 support then I don't think rsocket-java can commit as various APIs will break randomly due to usage or internal changes.

@yschimke
Copy link
Member

I'll put up the demo app as it is. I'm following up on reactor-core here reactor/reactor-core#796

@yschimke yschimke self-assigned this Aug 19, 2017
@NexZhu
Copy link
Author

NexZhu commented Aug 20, 2017

Unfortunately, I need to support at least SDK 22 so it seems like rsocket-java is not an option for now. Thank you anyways!

@yschimke
Copy link
Member

@NexZhu yep - rsocket-cpp works so feel free to file an issue on that project. But I hope they just ask you for a PR instead :)

@mostroverkhov
Copy link
Member

@NexZhu There is simpler way now with rsocket-android, working on SDK19 and above.

@yschimke
Copy link
Member

@mostroverkhov awesome, cc @robertroeser

Do you want to add a link from https://github.com/rsocket/rsocket-java/blob/1.0.x/README.md

Robert, how does this fit with your plans?

@mostroverkhov
Copy link
Member

@yschimke looking around to find people also interested in RSocket :neckbeard:. I think it would be sufficient to pin all implementations of RSocket in organization main page, and move example links into respective repositories.

@yschimke
Copy link
Member

@mostroverkhov actually I missed that this is in the rsocket repo anyway, so ignore my question.

@mwagens
Copy link

mwagens commented Jun 16, 2020

@lexs can you, please provide example of building rsocket-cpp for android for example. I tried with externalNativeBuild {
cmake "CMakeLists.txt"
}

but it does not seem to work.
I tried to create Shared library to dynamically link it, but the same result

@yschimke
Copy link
Member

@yschimke
Copy link
Member

Java 8 is supported now on Android down to 21 https://developer.android.com/studio/write/java8-support

So worth trying this first

@yschimke
Copy link
Member

I've updated this example which seems to be working well

https://github.com/rsocket/rsocket-demo-android-java8/blob/master/README.md

@yschimke
Copy link
Member

Yes! it is possible to generally use rsocket-java on Android as a client.

@dawud-tan
Copy link

Java 8 is supported now on Android down to 21 https://developer.android.com/studio/write/java8-support

So worth trying this first

@yschimke is it possible to use rsocket-java in Android below 21? The doc says that multiDexEnabled should be set to true, when setting minSdkVersion to 20 or lower.

  defaultConfig {
    // Required when setting minSdkVersion to 20 or lower
    multiDexEnabled true
  }

@yschimke
Copy link
Member

yschimke commented Sep 6, 2020

Not sure, haven't tried. If it works for you please update here.

With rsocket-java and Spring reactor, Android support is best effort.

See reactor/reactor-core#2227 which relates to a critical dependency of rsocket-java

@yschimke
Copy link
Member

yschimke commented Sep 6, 2020

You can also try https://github.com/rsocket/rsocket-kotlin/ not sure what the answer is here

@OlegDokuka
Copy link
Member

@dawud-tan better to raise an issue at https://github.com/rsocket/rsocket-kotlin/ mentioning required Java version, etc

@androiddevcoding
Copy link

@yschimke To use on Android. What do I need to implement?

@yschimke
Copy link
Member

yschimke commented Aug 3, 2023

I don't have a recent sample for you. Sorry. I don't know if Netty dependencies are an issue still with rsocket-java on android.

But rsocket-kotlin uses Ktor, which does work, instructions in that project docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants