【问题标题】:FATAL EXCEPTION: main java.lang.NoClassDefFoundError: org.apache.commons.net.ftp.FTPClient Android Studio致命异常:主要 java.lang.NoClassDefFoundError:org.apache.commons.net.ftp.FTPClient Android Studio
【发布时间】:2013-11-04 19:05:29
【问题描述】:

我知道这个问题有一些回复如下:

one

two

three

我正在使用 Android Studio:

所以我在 libs 文件夹中有这个库:

我修改了build.gradle:

buildscript {
repositories {
    mavenCentral()
}
dependencies {
    classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'

repositories {
mavenCentral()
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"

defaultConfig {
    minSdkVersion 11
    targetSdkVersion 18
}
}

dependencies {
    compile 'com.android.support:appcompat-v7:18.0.0'
    compile 'com.google.android.gms:play-services:3.1.36'
    compile files ('libs/commons-net-3.3.jar')
}

此活动使用我的 ftp:

...
import org.apache.commons.net.ftp.*;

public class GalleryActivity extends Activity {

private TextView debugText;
private FTPClient ftpClient;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_gellery);
    // Show the Up button in the action bar.
    setupActionBar();
    debugText =  (TextView) findViewById(R.id.debug_text);
    try {

        ftpClient = new FTPClient();
        ftpClient.connect("ftp.strefa.pl");
        Toast toast = Toast.makeText(getApplicationContext(),
                "polaczono",Toast.LENGTH_SHORT);
        toast.show();
        ftpClient.login("admin+ftpforproject.strefa.pl","studia12");
        toast = Toast.makeText(getApplicationContext(),
                "zalogowano",Toast.LENGTH_SHORT);
        toast.show();
        ftpClient.enterLocalPassiveMode();
        FTPFile[] fileList = ftpClient.listFiles();

        String fileNames = "";

        for(FTPFile file : fileList){
            fileNames+= file.getName() +"\n";
        }
        debugText.setText(fileNames);

    }catch (Exception e) {
        e.printStackTrace();
    }



}
...

我知道出了点问题,因为我在外部库中没有它:

我添加了谷歌服务库,它可以工作,我的地图正在渲染,但在图库中我没有这个运气。

我做错了什么?我很沮丧,请帮忙!

【问题讨论】:

    标签: java android ftp android-studio classnotfoundexception


    【解决方案1】:

    一段时间后,我重新启动了 IDE 并重建了一个项目(清理并构建),问题解决了。 不知道说什么,笨蛋Android Studio:/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-06-02
      • 2012-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-03
      相关资源
      最近更新 更多