File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Android and the fly likes Android Eclipse Emulator and FTP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "Android Eclipse Emulator and FTP" Watch "Android Eclipse Emulator and FTP" New topic
Author

Android Eclipse Emulator and FTP

Paul Kinzelman
Greenhorn

Joined: Aug 15, 2011
Posts: 3
I'm interested in doing just a simple FTP 'get' in my app. It works fine on the Palm Pre and WPF/C# and windows, but not the Android at least on the emulator and I can't find any examples from the searching I've done. I tried a simple:

but it gets an exception on getInputStream: Unable to connect to server: Unable to configure data port

And I know internet access works because I can do an http protocol request. I have the magical incantation in the manifest file to allow network access:
<uses-permission android:name="android.permission.INTERNET" />

Also, there must be a more intelligent way to pull the data out of the stream buffer than byte-by-byte, isn't there? I can't find that either.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42273
    
  64
I wouldn't rely on the URL ftp: scheme to work. The Apache Commons Net library has FTP client classes built in, and it works just fine on Android.


Ping & DNS - my free Android networking tools app
Paul Kinzelman
Greenhorn

Joined: Aug 15, 2011
Posts: 3
Too bad, the ftp URL scheme works fine on webOS and WPF/C#.

Could you please be a bit more specific about how to do what you suggest?
And how to make it work in the Eclipse/Emulator environment?

Would I need to refer a JAR library or something?

I tried the FTPClient library here: http://androiddev.orkitra.com/?p=139
but I can't get it to work either, says "NoClassDefFoundError" as though the library
is not available on the Emulator, but is available on Eclipse - the references get
resolved properly. It there some magical incantation I need in the AndroidManifest
file or something?

Thanks!
Paul Kinzelman
Greenhorn

Joined: Aug 15, 2011
Posts: 3
Whew! I finally got it going.

After fixing the library access (Project | Properties | Java Build Path | Libraries | Add JARs...) I fiddled with the calls until it started working. Here's the sequence of my FTPClient calls. It wouldn't work until I set it in passive mode.

 
Don't get me started about those stupid light bulbs.
 
subject: Android Eclipse Emulator and FTP