There is my code.
jcifs.Config.setProperty("jcifs.smb.client.enableSMB2","true");
jcifs.Config.setProperty("jcifs.smb.client.disableSMB1","true");
jcifs.Config.setProperty("jcifs.smb.client.useSMB2Negotiation","true");
jcifs.Config.setProperty("jcifs.smb.client.ipcSigningEnforced","false");
jcifs.Config.setProperty("jcifs.smb.client.maxVersion","SMB3");
jcifs.Config.setProperty("jcifs.smb.client.minVersion","SMB202");
jcifs.Config.setProperty("jcifs.smb.client.port139.enabled","true");
jcifs.Config.setProperty("jcifs.smb.client.enableSMB2","true");
ArrayList<NetWorkScanner.serverBean> servers = mNetWorkScanner.getServers();
Log.i(TAG,"mNetWorkScanner : " + servers);
Log.i(TAG,"mNetWorkScanner len : " + servers.size());
if(servers != null && servers.size() > 0) {
new Thread(new Runnable() {
@Override
public void run() {
for(NetWorkScanner.serverBean info : servers) {
try {
final String url = "smb://" + info.serverIp + "/share";
if(info.serverIp.equals("192.168.0.9")) continue;
SmbFile temp = new SmbFile(url);
try{
Log.i(TAG,"temp.list() : " + temp.listFiles());
Log.i(TAG,"temp.getDfsPath() : " + temp.getDfsPath());
} catch( SmbException sbex ) {
Log.i(TAG, "error sbex : " + sbex);
throw new Error(sbex);
}
} catch( MalformedURLException ex ) {
Log.i(TAG, "error ex : " + ex);
}
}
}
}).start();
}
And, there is the error Log.
2020-09-28 09:38:52.121 5224-6765/com.android.tv.settings E/AndroidRuntime: FATAL EXCEPTION: Thread-261
Process: com.android.tv.settings, PID: 5224
java.lang.Error: jcifs.smb.SmbException: Failed to connect: 0.0.0.0<00>/192.168.0.2
jcifs.util.transport.TransportException
jcifs.smb.SmbException: This client does not support the negotiated dialect.
at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:329)
at jcifs.util.transport.Transport.run(Transport.java:241)
at java.lang.Thread.run(Thread.java:764)
at jcifs.util.transport.Transport.run(Transport.java:258)
at java.lang.Thread.run(Thread.java:764)
at com.android.tv.settings.device.networkstorage.AvailableNetworkStorageFragment$1.run(AvailableNetworkStorageFragment.java:96)
at java.lang.Thread.run(Thread.java:764)
Caused by: jcifs.smb.SmbException: Failed to connect: 0.0.0.0<00>/192.168.0.2
jcifs.util.transport.TransportException
jcifs.smb.SmbException: This client does not support the negotiated dialect.
at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:329)
at jcifs.util.transport.Transport.run(Transport.java:241)
at java.lang.Thread.run(Thread.java:764)
at jcifs.util.transport.Transport.run(Transport.java:258)
at java.lang.Thread.run(Thread.java:764)
at jcifs.smb.SmbTransport.connect(SmbTransport.java:309)
at jcifs.smb.SmbTree.treeConnect(SmbTree.java:156)
at jcifs.smb.SmbFile.doConnect(SmbFile.java:911)
at jcifs.smb.SmbFile.connect(SmbFile.java:957)
at jcifs.smb.SmbFile.connect0(SmbFile.java:880)
at jcifs.smb.SmbFile.getType(SmbFile.java:1285)
at jcifs.smb.SmbFile.doEnum(SmbFile.java:1736)
at jcifs.smb.SmbFile.listFiles(SmbFile.java:1718)
at jcifs.smb.SmbFile.listFiles(SmbFile.java:1651)
at com.android.tv.settings.device.networkstorage.AvailableNetworkStorageFragment$1.run(AvailableNetworkStorageFragment.java:90)
I want to get shared directory name using ip address where samba is running on my local netwrok. but, I think there is something wrong with samba and jcifs libs to connect! I using Samba : 4.11.6-Ubuntu in Ubuntu 20.0.4 and jcifs-1.3.19.jar to local static libs in Android. Any help please..