非常简单,我正在关注网站上设置的web3j,当试图将最新版本恢复测试时,它连接到testrpc,它会抛出一个SocketException。
它在网站上说新的HttpService()默认为localhost:8545,这是我运行的testrpc。我还在清单中设置了互联网权限。
//imports etc
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home_screen);
Web3j web3 = Web3jFactory.build(new HttpService());
try {
Web3ClientVersion clientVersion =
web3.web3ClientVersion().sendAsync().get(); //here is where thrown
String clientVers = clientVersion.getWeb3ClientVersion();
Log.d("hello", clientVers);
}
catch(InterruptedException e){
e.printStackTrace();
}
catch(ExecutionException e){
e.printStackTrace(); //throws as SocketException
}
}
//other code that has nothing to do with web3j
很抱歉,如果这显而易见,任何帮助都会令人惊叹。感谢。