Android Studio中库的NoClassDefFoundError

我花了好几个小时的时间试图让我的项目在Android Studio中工作,我只是无法弄清楚。

以下是我的模块的依赖关系 在这里输入图像说明

和我的图书馆: http://i.imgur.com/t8E3sB8.png

我甚至添加了

compile files('libs/signpost-commonshttp4-1.2.1.2.jar') compile files('libs/signpost-core-1.2.1.2.jar') 

到我的build.gradle。 没有这个,应用程序甚至不会编译。

在这个阶段,当我尝试在代码中引用其中一个库时,应用程序崩溃,出现NoClassDefFoundErrorexception。

有些事情告诉我这不应该是这么难 – 我忽略了什么?

logcat的:

 05-17 21:51:15.676: I/ActivityManager(714): START u0 {flg=0x10104000 cmp=com.crazydog.splitwiser/.InitialSplash bnds=[328,402][656,692]} from pid 1513 05-17 21:51:15.896: I/ActivityManager(714): Start proc com.crazydog.splitwiser for activity com.crazydog.splitwiser/.InitialSplash: pid=18174 uid=10288 gids={50288, 3003, 1028} 05-17 21:51:16.326: I/ActivityManager(714): Displayed com.crazydog.splitwiser/.InitialSplash: +437ms (total +1m9s209ms) 05-17 21:51:17.017: I/ActivityManager(714): START u0 {cmp=com.crazydog.splitwiser/.LogIn} from pid 18174 05-17 21:51:17.097: E/dalvikvm(18174): Could not find class 'oauth.signpost.commonshttp.CommonsHttpOAuthConsumer', referenced from method com.crazydog.splitwiser.Toolkit.oAuthTransaction 05-17 21:51:17.097: W/dalvikvm(18174): VFY: unable to resolve new-instance 662 (Loauth/signpost/commonshttp/CommonsHttpOAuthConsumer;) in Lcom/crazydog/splitwiser/Toolkit; 05-17 21:51:17.097: D/dalvikvm(18174): DexOpt: unable to opt direct call 0x112f at 0x08 in Lcom/crazydog/splitwiser/Toolkit;.oAuthTransaction 05-17 21:51:17.107: E/AndroidRuntime(18174): at com.crazydog.splitwiser.Toolkit.oAuthTransaction(Toolkit.java:65) 05-17 21:51:17.107: E/AndroidRuntime(18174): at com.crazydog.splitwiser.LogIn.onResume(LogIn.java:116) 05-17 21:51:17.117: W/ActivityManager(714): Force finishing activity com.crazydog.splitwiser/.LogIn 05-17 21:51:17.117: W/ActivityManager(714): Force finishing activity com.crazydog.splitwiser/.InitialSplash 05-17 21:51:17.618: W/ActivityManager(714): Activity pause timeout for ActivityRecord{40d040d0 u0 com.crazydog.splitwiser/.LogIn} 

Solutions Collecting From Web of "Android Studio中库的NoClassDefFoundError"

我有完全相同的问题,就像你我认为这是足以添加

 compile files('libs/signpost-commonshttp4-1.2.1.2.jar') compile files('libs/signpost-core-1.2.1.2.jar') 

这一切工作后,我做了一个./gradlew clean (我在Mac上,所以在你的情况下,等效。)当你位于你的项目的根目录时,你应该从terminal/命令提示符执行此命令。