简体   繁体   中英

Android FTP upload error: NoClassDefFoundError

I got this ftp upload method:

try {
    SimpleFTP ftp = new SimpleFTP();

    // Connect to an FTP server on port 21.
    ftp.connect("ftp.atw.hu", 21, "username", "password");

    // Set binary mode.
    ftp.bin();

    // Change to a new working directory on the FTP server.
    ftp.cwd("web");

    // Upload some files.
    ftp.stor(new File("/mnt/sdcard/Documents/Festivale.db"));
    //ftp.stor(new File("comicbot-latest.png"));

    // You can also upload from an InputStream, e.g.
    // ftp.stor(new FileInputStream(new File("test.png")), "test.png");
    // ftp.stor(someSocket.getInputStream(), "blah.dat");

    // Quit from the FTP server.
    ftp.disconnect();
} catch (IOException e) {
    // Jibble.
}

I got force close with the following log:

08-27 14:26:09.037: E/AndroidRuntime(2378): FATAL EXCEPTION: main
08-27 14:26:09.037: E/AndroidRuntime(2378): java.lang.NoClassDefFoundError: org.jibble.simpleftp.SimpleFTP
08-27 14:26:09.037: E/AndroidRuntime(2378):     at com.example.festivale_v2.main$8.onClick(main.java:106)
08-27 14:26:09.037: E/AndroidRuntime(2378):     at android.view.View.performClick(View.java:2485)
08-27 14:26:09.037: E/AndroidRuntime(2378):     at android.view.View$PerformClick.run(View.java:9080)
08-27 14:26:09.037: E/AndroidRuntime(2378):     at android.os.Handler.handleCallback(Handler.java:587)
08-27 14:26:09.037: E/AndroidRuntime(2378):     at android.os.Handler.dispatchMessage(Handler.java:92)
08-27 14:26:09.037: E/AndroidRuntime(2378):     at android.os.Looper.loop(Looper.java:123)
08-27 14:26:09.037: E/AndroidRuntime(2378):     at android.app.ActivityThread.main(ActivityThread.java:3683)
08-27 14:26:09.037: E/AndroidRuntime(2378):     at java.lang.reflect.Method.invokeNative(Native Method)
08-27 14:26:09.037: E/AndroidRuntime(2378):     at java.lang.reflect.Method.invoke(Method.java:507)
08-27 14:26:09.037: E/AndroidRuntime(2378):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-27 14:26:09.037: E/AndroidRuntime(2378):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-27 14:26:09.037: E/AndroidRuntime(2378):     at dalvik.system.NativeStart.main(Native Method)

Can someone tell me whats wrong? I've tried it on my phone resulting in the same error. It has internet permission.

The SimpleFTP class obviously cannot be found.

You should check your classpath (project properties > Java build path):

  • In the Libraries tab: add the corresponding jar
  • In Order and Export: check the jar so that it's exported

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM