[Java for Android App Development] JamesChilds:
Can anyone here help me getting ftp4j running in my app? I have written what should just connect then disconnect but it crashes the app. I have googled ALL OVER and can NOT figure out how to get it implemented. Any help appreciated.

EDIT: What I was REALLY asking for was what YOU would do to make it work, but I'll post my non functioning code I guess. FYI I did give permissions for internet.

Main.java:

package com.JKIC.pictures;

import java.io.IOException;

import it.sauronsoftware.ftp4j.FTPClient;

import it.sauronsoftware.ftp4j.FTPException;

import it.sauronsoftware.ftp4j.FTPIllegalReplyException;

import android.os.Bundle;

import android.app.Activity;

import android.view.Menu;

import android.widget.TextView;

public class Main extends Activity {

[MENTION=439709]override[/MENTION]

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

try {

FTPClient ftp = new FTPClient();

ftp.connect("xxx.com);

ftp.login("xxx", "xxx");

ftp.disconnect(true);

} catch (IllegalStateException e) {

String test = e.toString();

TextView testview = (TextView) findViewById(R.id.textView1);

testview.setText(test);

} catch (IOException e) {

String test = e.toString();

TextView testview = (TextView) findViewById(R.id.textView1);

testview.setText(test);

} catch (FTPIllegalReplyException e) {

String test = e.toString();

TextView testview = (TextView) findViewById(R.id.textView1);

testview.setText(test);

} catch (FTPException e) {

String test = e.toString();

TextView testview = (TextView) findViewById(R.id.textView1);

testview.setText(test);

}

}

[MENTION=439709]override[/MENTION]

public boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present.

getMenuInflater().inflate(R.menu.main, menu);

return true;

}

}

Logcat:

07-16 00:20:42.000: E/Trace(3518): error opening trace file: No such file or directory (2)

07-16 00:20:42.580: D/AndroidRuntime(3518): Shutting down VM

07-16 00:20:42.580: W/dalvikvm(3518): threadid=1: thread exiting with uncaught exception (group=0x40a71930)

07-16 00:20:42.610: E/AndroidRuntime(3518): FATAL EXCEPTION: main

07-16 00:20:42.610: E/AndroidRuntime(3518): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.JKIC.pictures/com.JKIC.pictures.Main}: android.os.NetworkOnMainThreadException

07-16 00:20:42.610: E/AndroidRuntime(3518):	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)

07-16 00:20:42.610: E/AndroidRuntime(3518):	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)

07-16 00:20:42.610: E/AndroidRuntime(3518):	at android.app.ActivityThread.access$600(ActivityThread.java:141)

07-16 00:20:42.610: E/AndroidRuntime(3518):	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)

07-16 00:20:42.610: E/AndroidRuntime(3518):	at android.os.Handler.dispatchMessage(Handler.java:99)

07-16 00:20:42.610: E/AndroidRuntime(3518):	at android.os.Looper.loop(Looper.java:137)

07-16 00:20:42.610: E/AndroidRuntime(3518):	at android.app.ActivityThread.main(ActivityThread.java:5041)

07-16 00:20:42.610: E/AndroidRuntime(3518):	at java.lang.reflect.Method.invokeNative(Native Method)

07-16 00:20:42.610: E/AndroidRuntime(3518):	at java.lang.reflect.Method.invoke(Method.java:511)

07-16 00:20:42.610: E/AndroidRuntime(3518):	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)

07-16 00:20:42.610: E/AndroidRuntime(3518):	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)

07-16 00:20:42.610: E/AndroidRuntime(3518):	at dalvik.system.NativeStart.main(Native Method)

07-16 00:20:42.610: E/AndroidRuntime(3518): Caused by: android.os.NetworkOnMainThreadException

07-16 00:20:42.610: E/AndroidRuntime(3518):	at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)

07-16 00:20:42.610: E/AndroidRuntime(3518):	at java.net.InetAddress.lookupHostByName(InetAddress.java:385)

07-16 00:20:42.610: E/AndroidRuntime(3518):	at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)

07-16 00:20:42.610: E/AndroidRuntime(3518):	at java.net.InetAddress.getByName(InetAddress.java:289)

07-16 00:20:42.610: E/AndroidRuntime(3518):	at java.net.InetSocketAddress.<init>(InetSocketAddress.java:105)

07-16 00:20:42.610: E/AndroidRuntime(3518):	at java.net.InetSocketAddress.<init>(InetSocketAddress.java:90)

07-16 00:20:42.610: E/AndroidRuntime(3518):	at it.sauronsoftware.ftp4j.FTPConnector.tcpConnectForCommunicationChannel(FTPConnector.java:208)

07-16 00:20:42.610: E/AndroidRuntime(3518):	at it.sauronsoftware.ftp4j.connectors.DirectConnector.connectForCommunicationChannel(DirectConnector.java:39)

07-16 00:20:42.610: E/AndroidRuntime(3518):	at it.sauronsoftware.ftp4j.FTPClient.connect(FTPClient.java:1036)

07-16 00:20:42.610: E/AndroidRuntime(3518):	at it.sauronsoftware.ftp4j.FTPClient.connect(FTPClient.java:1003)

07-16 00:20:42.610: E/AndroidRuntime(3518):	at com.JKIC.pictures.Main.onCreate(Main.java:22)

07-16 00:20:42.610: E/AndroidRuntime(3518):	at android.app.Activity.performCreate(Activity.java:5104)

07-16 00:20:42.610: E/AndroidRuntime(3518):	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)

07-16 00:20:42.610: E/AndroidRuntime(3518):	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)

07-16 00:20:42.610: E/AndroidRuntime(3518):	... 11 more

07-16 00:20:42.760: D/dalvikvm(3518): GC_CONCURRENT freed 234K, 12% free 2630K/2980K, paused 6ms+4ms, total 170ms