Can't connect Android app to Ganache using retrofit

by giusha9   Last Updated April 14, 2019 22:28 PM

I'm have deployed contracts on ethereum blockchain. I have ganache running on server

I'm tring to connect to it from android with this code:

private BlockChainService() {
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl("http://127.0.0.1:8545/")
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .build();
        blockChainApi = retrofit.create(BlockChainApi.class);
    }

But it's raising exception with the message - "failed to connect to /127.0.0.1:8545". I've tried opening the app from genymotion emulator and from the actual device also but the problem is still the same.

I also have spring boot application which is successfully connecting with ganache using exactly the same code. So my guess is that it's related to network.

So my question is how can I connect from android app to ganache? Is it a problem with the network?



Related Questions


Updated November 19, 2017 20:28 PM

Updated July 25, 2017 17:28 PM

Updated December 27, 2017 12:28 PM

Updated September 23, 2017 15:28 PM

Updated December 27, 2017 13:28 PM