2013-11-04 101 views
1

我知道,這個問題有一定的回覆爲:致命異常:主要java.lang.NoClassDefFoundError:org.apache.commons.net.ftp.FTPClient Android Studio中

one

two

three

我使用過Android Studio:

,所以我有這個LIB在libs文件夾: 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

我已經添加了谷歌服務庫,它的工作原理,我的地圖正在渲染,但在圖庫中我沒有這個運氣。

我做錯了什麼?我很沮喪,請幫忙!

回答

2

經過一段時間我重新啓動了IDE並重建了一個項目(clean and build),問題解決了。 我不知道該說些什麼,虛擬Android Studio:/