Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8540025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:30:22+00:00 2026-06-11T11:30:22+00:00

I created an Android app which has an FTP connection, however when I start

  • 0

I created an Android app which has an FTP connection, however when I start the app it says “unfortunately your app must stopped”, and I can’t find the problem.
I tried to enter local passive mode however it didn’t help me, I also tried to run the app on my phone however it gave me the same message.

import java.io.IOException;
import org.apache.commons.net.ftp.FTPClient;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.os.AsyncTask;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.widget.Button;
import android.widget.TextView;


public class MainActivity extends Activity implements OnClickListener {
    Button scan;
    String contents;
    String format;
    TextView contentstext;
    TextView formattext;
    FTPClient  ftpclient;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //----------------------FTP-------------
        new FtpTask().execute();
        //ftpclient.enterLocalPassiveMode();
        try {
        ftpclient.changeToParentDirectory();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }




        scan=(Button)findViewById(R.id.scanbutton);
        contentstext=(TextView)findViewById(R.id.contentstext);
        formattext=(TextView)findViewById(R.id.formattext);
        scan.setOnClickListener(this);

    }

    private class FtpTask extends AsyncTask<Void, Void, FTPClient> {
        protected FTPClient doInBackground(Void... args) {
            FTPClient  ftp = new FTPClient ();
            try {
                ftp.connect("ftp.drivehq.com");
                ftp.login("zule","****");
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
           return ftp;
        }

        protected void onPostExecute(FTPClient result) {
            Log.v("FTPTask","FTP connection complete");
            ftpclient = result;
        }

    }

here is the logcat:

09-17 12:11:30.319: E/AndroidRuntime(1113): FATAL EXCEPTION: main
09-17 12:11:30.319: E/AndroidRuntime(1113): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.market/com.example.market.MainActivity}: java.lang.NullPointerException
09-17 12:11:30.319: E/AndroidRuntime(1113):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
09-17 12:11:30.319: E/AndroidRuntime(1113):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
09-17 12:11:30.319: E/AndroidRuntime(1113):     at android.app.ActivityThread.access$600(ActivityThread.java:123)
09-17 12:11:30.319: E/AndroidRuntime(1113):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
09-17 12:11:30.319: E/AndroidRuntime(1113):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-17 12:11:30.319: E/AndroidRuntime(1113):     at android.os.Looper.loop(Looper.java:137)
09-17 12:11:30.319: E/AndroidRuntime(1113):     at android.app.ActivityThread.main(ActivityThread.java:4424)
09-17 12:11:30.319: E/AndroidRuntime(1113):     at java.lang.reflect.Method.invokeNative(Native Method)
09-17 12:11:30.319: E/AndroidRuntime(1113):     at java.lang.reflect.Method.invoke(Method.java:511)
09-17 12:11:30.319: E/AndroidRuntime(1113):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-17 12:11:30.319: E/AndroidRuntime(1113):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-17 12:11:30.319: E/AndroidRuntime(1113):     at dalvik.system.NativeStart.main(Native Method)
09-17 12:11:30.319: E/AndroidRuntime(1113): Caused by: java.lang.NullPointerException
09-17 12:11:30.319: E/AndroidRuntime(1113):     at com.example.market.MainActivity.onCreate(MainActivity.java:32)
09-17 12:11:30.319: E/AndroidRuntime(1113):     at android.app.Activity.performCreate(Activity.java:4465)
09-17 12:11:30.319: E/AndroidRuntime(1113):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
09-17 12:11:30.319: E/AndroidRuntime(1113):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
09-17 12:11:30.319: E/AndroidRuntime(1113):     ... 11 more
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T11:30:24+00:00Added an answer on June 11, 2026 at 11:30 am

    Look at the stack trace. It says you have a NullPointerException on line 32.
    If I counted right, that’s this line:

    ftpclient.changeToParentDirectory();
    

    Notice that your class member ftpClient is not instantiated; so it’s still null when you try to call changeToParentDirectory() on it.

    Adding ftpClient = new FtpClient( ... ) somewhere before this call should solve your problem. Add the correct parameters for the dots.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created app in android, everywhere looks great, but on the phone which has
I Have created an android app, which has view flipper and it has 4
I have an Android app created with Adobe AIR and Flex. How can I
I am having another problem with my android app which I can't find an
I am new to android.. I had created an application (AgentApp) which has an
I am developing an android app which has Facebook integration in it. I have
I am developing an android app which has a button in one activity and
i have created an app which has a TextView which contain some text. i
I am writing an Android app that has a Button which calls SelfDestruct() .
I have a Android App I have developed, It has been created from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.