Reputation: 175
This is an updated version of a question I asked last week.
I'm trying to use SmbFileInputStream to connect my Android to my PC,
but the app aborts (on my tablet) with this error message:
"The application has stopped unexpectedly. Please try again."
I'm using Try/Catch but it doesn't trigger any of those exceptions.
The applicable code looks like this:
SmbFile inFile = null;
jcifs.Config.setProperty( "jcifs.netbios.wins", "192.168.2.2" ) }
try { inFile = new SmbFileInputStream( "smb://MIKE-PC/Users/Public/List1.txt" ); }
catch (SmbException e) { ListItems.add("SMB Error"); }
catch (MalformedURLException e) { ListItems.add("URL Error"); }
catch (UnknownHostException e) { ListItems.add("Host Error"); }
I tried the code with and without the name and password, and neither worked:
try { inFile = new SmbFile( "smb://MIKE-PC_Network:123ABC@Mike-PC/" ); }
When I try doing it in two steps, the SmbFile does not abort but the SmbFileInputStream does.
try { sFile = new SmbFile( "smb://MIKE-PC/Users/Public/List1.txt" ); }
try { inFile = new SmbFileInputStream( sFile ); }
When I try getting a file list, the SmbFile does not abort but the sFile.list does.
try { sFile = new SmbFile( "smb://MIKE-PC/" ); }
try { lBuf = sFile.list(); . . .
I'm on a local network, not a domain.
The tablet was able to log on with another app, so I know the network works.
I've tried the user, network, PC names in every combination possible.
Is there some additional info that SMB needs before it will work?
For example, after days of searching the web, I've seen hints of:
* The Java SMB will not work in Android - is that true and which do I have?
* Putting the jcifs.jar in the libs folder will not work with jcifs.
* Do I need to add the jCIFS jar file to the CLASSPATH, or is that handled by Eclipse?
* Do I need to call registerSmbURLHandler if I give SmbFileInputStream a literal string?
* Is there a read-external permission that needs to go in the manifest?
Is any of that true, and what do I do about it?
Upvotes: 0
Views: 2175
Reputation: 1421
I'm also having the same problem, but I just wanted to partially answer your question by adding in a few catches that you should include in your code so that it doesn't do a hard crash.
Here are the catches that I've added in my code
catch (SmbException
| MalformedURLException
| UnknownHostException
| NetworkOnMainThreadException
| ExceptionInInitializerError e)
If I find any more information I'll edit this post.
Upvotes: 0
Reputation: 444
did you try "smb://username:password@local ip/" do it with the actual IP address. for me I had to do it with IP, with computer name my app never connected to windows share and crashed.
Upvotes: 1