I develop an android project.It is about JSCH.I setup a server and i want to connect with android code.I found required code but it works android 2.3.3,i need code or modify for 4.0.3.Code works in 2.3.3 but it crash at 4.0.3.Please help me
JSch jsch = new JSch();
Session session = null;
session = jsch.getSession("******", "*********",22);
session.setConfig("StrictHostKeyChecking", "no");
session.setPassword("******");
session.connect();
Channel channel = session.openChannel("sftp");
channel.connect();
ChannelSftp sftpChannel = (ChannelSftp) channel;
sftpChannel.exit();
session.disconnect();
Since you’ve refrained from giving us a stack trace, I’m giving this answer with a bit of guessing.
My guess is you’re getting a
NetworkOnMainThreadException. This exception occurs on Android 3.0 and above, when you try to use the network on the main UI thread. This also explains why you don’t see the exception on Gingerbread.To fix this, move all networking code into a Thread or an AsyncTask.