2015-02-23 62 views
4

我從git中克隆了一個項目,並在作爲等級構建的一部分中添加了一些庫。這是代碼從git導入項目時出現NoClassDefFound錯誤

apply plugin: 'com.android.application' 

android { 
compileSdkVersion 21 
buildToolsVersion "21.1.2" 

defaultConfig { 
    applicationId "co.example.android" 
    minSdkVersion 14 
    targetSdkVersion 21 
    versionCode 1 
    versionName "1.0" 
} 
buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'),       'proguard-rules.pro' 
    } 
} 
} 
repositories { mavenCentral() } 
dependencies { 
compile fileTree(include: ['*.jar'], dir: 'libs') 
compile 'com.android.support:appcompat-v7:21.0.3' 
compile 'com.loopj.android:android-async-http:1.4.6' 
compile 'com.squareup.picasso:picasso:2.4.0' 
compile 'de.hdodenhof:circleimageview:1.2.1' 
compile 'com.facebook.android:facebook-android-sdk:3.21.1' 
} 

這的gradle這個依賴部分家長的build.gradle文件

// Top-level build file where you can add configuration options common to all sub-projects/modules. 

buildscript { 
repositories { 
    jcenter() 
} 
dependencies { 
    classpath 'com.android.tools.build:gradle:1.0.0' 

    // NOTE: Do not place your application dependencies here; they belong 
    // in the individual module build.gradle files 
} 
} 

allprojects { 
repositories { 
    jcenter() 
} 
} 

但是在同步的項目中,我得到以下錯誤的logcat

5:51:36 PM NoClassDefFoundError: org/jetbrains/idea/maven/model/MavenArtifactInfo: org/jetbrains/idea/maven/model/MavenArtifactInfo 5:51:41 PM NoClassDefFoundError: Could not initialize class com.android.tools.idea.structure.MavenDependencyLookupDialog: Could not initialize class com.android.tools.idea.structure.MavenDependencyLookupDialog 5:51:49 PM NoClassDefFoundError: Could not initialize class com.android.tools.idea.structure.MavenDependencyLookupDialog: Could not initialize class com.android.tools.idea.structure.MavenDependencyLookupDialog 5:51:55 PM NoClassDefFoundError: Could not initialize class com.android.tools.idea.structure.MavenDependencyLookupDialog: Could not initialize class com.android.tools.idea.structure.MavenDependencyLookupDialog 5:52:10 PM NoClassDefFoundError: Could not initialize class com.android.tools.idea.structure.MavenDependencyLookupDialog: Could not initialize class com.android.tools.idea.structure.MavenDependencyLookupDialog 5:53:32 PM NoClassDefFoundError: Could not initialize class com.android.tools.idea.structure.MavenDependencyLookupDialog: Could not initialize class com.android.tools.idea.structure.MavenDependencyLookupDialog 5:56:56 PM NoClassDefFoundError: Could not initialize class com.android.tools.idea.structure.MavenDependencyLookupDialog: Could not initialize class com.android.tools.idea.structure.MavenDependencyLookupDialog 6:03:26 PM NoClassDefFoundError: Could not initialize class com.android.tools.idea.structure.MavenDependencyLookupDialog: Could not initialize class com.android.tools.idea.structure.MavenDependencyLookupDialog

+0

顯示整個build.gradle文件和父目錄中的所有父build.gradle文件 – 2015-02-23 12:48:28

回答

3

發生此問題是因爲我已經檢查了gradle設置中的離線工作。解除工作後工作

+0

可以請你解釋你是如何工作的 – dhpratik 2015-08-20 07:19:00

+1

goto file-> other settings-> default settings-> Build,execution and deployement->建立工具 - > gradle->不使用離線工作,如果它檢查..希望這可以幫助 – 2015-08-20 12:42:42

+0

羅伊斯拉朱謝謝 – dhpratik 2015-08-20 15:37:57

1

在另一臺機器上檢查了這個(非最新的DEV版本)。在那裏檢查「Maven集成」複選框,一切正常。更新到最新的DEV構建 - 仍然一切正常。所以,貌似,東西已損壞我的配置和檢查

"Studio_File -> Settings -> Plugins" plugin "Maven Integration" 

是解決方案。 無論如何,如果相應的插件被禁用,我強烈建議禁用「添加庫依賴性」(+澄清工具提示)菜單項。或者,至少,拋出另一個可以理解的例外,以節省用戶的時間,誰將面臨這個問題。 (我希望我不是最後一個,遇到這個)

For Brief請參閱here