grpc Server running on Android

776 views
Skip to first unread message

anilm...@gmail.com

unread,
Aug 31, 2016, 7:28:57 PM8/31/16
to grpc.io
Is there an example or implementation of GRPC server (Java/C++) running on Android?
I am following grpc java server example to implement the server i

private class GrpcServerTask extends AsyncTask<Void, Void, String>{

    @Override
    protected void onPreExecute() {
    }
    @Override
    protected String doInBackground(Void... params) {
        int port = 50051;
        Server server;
        try {
            server = ServerBuilder.forPort(port)
                    .addService(new GreeterImpl())
                    .build()
                    .start();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}

private class GreeterImpl extends GreeterGrpc.GreeterImplBase {

    @Override
    public void sayHello(HelloRequest req, StreamObserver<HelloReply> responseObserver) {
        HelloReply reply = HelloReply.newBuilder().setMessage("Hello " + req.getName()).build();
        responseObserver.onNext(reply);
        responseObserver.onCompleted();
    }
}

I keep getting the error io.grpc.ManagedChannelProvider$ProviderNotFoundException: No functional server found. Try adding a dependency on the grpc-netty artifact
on executing new GrpcServerTask().execute();

Thanks,
Anil

Carl Mastrangelo

unread,
Sep 13, 2016, 7:17:38 PM9/13/16
to grpc.io, anilm...@gmail.com
There isn't support for running a Java Server on Android currently.  If you want to do in process communication, we do have support for that.

As for your specific error, it happens because we use a ServiceLoader to find implementations.  We don't have such a file on Android.  You may want to use C++ in your case.

Carl Mastrangelo

unread,
Sep 14, 2016, 6:11:35 PM9/14/16
to grpc.io, anilm...@gmail.com
As a followup, I am kind of curious what your use case is?  

I have created a tracking issue here https://github.com/grpc/grpc-java/issues/2273 .  Feel free to ping that issue.
Reply all
Reply to author
Forward
0 new messages