我创建了一个端口转发到我的本地(虚拟-> 192.168.1.56)ftpserver。当我尝试使用 FileZilla 从主机(192.168.1.47)连接时,它可以工作:
当我使用 android 设备尝试时,出现以下错误:
05-18 11:18:00.479: E/Trace(1231): error opening trace file: No such file or directory (2)
05-18 11:18:00.840: D/dalvikvm(1231): GC_FOR_ALLOC freed 37K, 7% free 2412K/2592K, paused 80ms, total 97ms
05-18 11:18:00.900: I/dalvikvm-heap(1231): Grow heap (frag case) to 6.493MB for 4194320-byte allocation
05-18 11:18:00.960: D/dalvikvm(1231): GC_FOR_ALLOC freed 1K, 3% free 6507K/6692K, paused 58ms, total 58ms
05-18 11:18:01.049: D/dalvikvm(1231): GC_CONCURRENT freed <1K, 3% free 6507K/6692K, paused 4ms+4ms, total 89ms
05-18 11:18:02.609: E/sdcard-err2:(1231): println needs a message
05-18 11:18:02.802: V/Error(1231): java.io.IOException: Host attempting data connection 192.168.1.56 is not same as server 92.105.134.53
05-18 11:18:02.802: W/System.err(1231): java.io.IOException: Host attempting data connection 192.168.1.56 is not same as server 92.105.134.53
05-18 11:18:02.809: W/System.err(1231): at org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:525)
05-18 11:18:02.809: W/System.err(1231): at org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:2296)
05-18 11:18:02.819: W/System.err(1231): at org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:2269)
05-18 11:18:02.819: W/System.err(1231): at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2046)
05-18 11:18:02.819: W/System.err(1231): at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2093)
05-18 11:18:02.819: W/System.err(1231): at spicysoftware.getthepicture.newestPictures.connectFTP(newestPictures.java:232)
05-18 11:18:02.819: W/System.err(1231): at spicysoftware.getthepicture.newestPictures$2.run(newestPictures.java:116)
05-18 11:18:02.819: W/System.err(1231): at java.lang.Thread.run(Thread.java:856)
05-18 11:18:02.909: I/Choreographer(1231): Skipped 34 frames! The application may be doing too much work on its main thread.
05-18 11:18:02.929: D/gralloc_goldfish(1231): Emulator without GPU emulation detected.
05-18 11:18:04.192: I/Choreographer(1231): Skipped 42 frames! The application may be doing too much work on its main thread.
05-18 11:18:15.121: I/Choreographer(1231): Skipped 43 frames! The application may be doing too much work on its main thread.
05-18 11:22:08.110: I/Choreographer(1231): Skipped 49 frames! The application may be doing too much work on its main thread.
05-18 11:22:10.229: I/Choreographer(1231): Skipped 230 frames! The application may be doing too much work on its main thread.
代码:
它崩溃了
**Log.v("FTP STATUS: ",ftpClient.getStatus());**
public void connectFTP(String host, String username, String password){
try {
ftpClient = new FTPClient();
while (ftpClient.isConnected()==false){
ftpClient.connect(host, 49501);
ftpClient.login(username, password);
ftpClient.enterLocalPassiveMode();
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
}
ftpClient.changeWorkingDirectory("/thumbs");
try{
//HERE IT IS CRASHING.....
Log.v("FTP STATUS: ",ftpClient.getStatus());
}catch(Exception ex){
String err = (ex.getMessage()==null)?"SD Card failed":ex.getMessage();
Log.e("sdcard-err2:",err);
}
FTPFile[] files = ftpClient.listFiles();
insert_arraylist = "";
for (FTPFile file : files) {
imageNames.add(file.getName());
}
}