致命异常:主要java.lang.NoClassDefFoundError:org.apache.commons.net.ftp.FTPClient Android Studio

时间:2013-11-04 19:05:30

标签: java android ftp android-studio classnotfoundexception

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

one

two

three

我正在使用Android Studio:

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

module 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();
    }



}
...

我知道有些事情是错的,因为我在外部库中没有它:

external library

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

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

1 个答案:

答案 0 :(得分:2)

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

相关问题