NoClassDefFoundError的,在Android的工作室库工作室、NoClassDefFoundError、Android

2023-09-12 07:23:17 作者:很酷的小仙女

我已经花了几个小时试图让库与我的Andr​​oid Studio项目的工作,我只是不明白。

下面就是我的依赖性看起来像我的模块

和我的库:

我还添加

 编译文件(库/路标,commonshttp4-1.2.1.2.jar)
编译文件(库/路标核心 -  1.2.1.2.jar)
 
Android 12已在 AOSP 中上线

我build.gradle。没有这一点,应用程序甚至不会编译。

在这个阶段,当我尝试引用code中的图书馆之一,应用程序崩溃与出现NoClassDefFoundError例外。

东西告诉我,这不应该是这样的难 - 我是什么俯瞰

LogCat中:

  05-17 21:51:15.676:I / ActivityManager(714):开始U0 {FLG = 0x10104000 CMP = com.crazydog.splitwiser / .InitialSplash bnds = [328402] [ 656692]}从PID 1513
05-17 21:51:15.896:I / ActivityManager(714):启动PROC com.crazydog.splitwiser的活动com.crazydog.splitwiser / .InitialSplash:PID = 18174的uid = 10288导报= {50288,3003,1028}
05-17 21:51:16.326:I / ActivityManager(714):显示com.crazydog.splitwiser / .InitialSplash:+ 437ms(总+ 1m9s209ms)
05-17 21:51:17.017:I / ActivityManager(714):开始U0 {CMP = com.crazydog.splitwiser / .login文件}从PID 18174
05-17 21:51:17.097:E / dalvikvm(18174):找不到类的oauth.signpost.commonshttp.CommonsHttpOAuthConsumer,从法com.crazydog.splitwiser.Toolkit.oAuthTransaction引用
05-17 21:51:17.097:W / dalvikvm(18174):VFY:无法662(Loauth /路标/ commonshttp / CommonsHttpOAuthConsumer)解决新实例中LCOM / crazydog / splitwiser /工具包;
05-17 21:51:17.097:D / dalvikvm(18174):DexOpt:无法选择直接调用0x112f在0x08的在LCOM / crazydog / splitwiser /工具包; .oAuthTransaction
05-17 21:51:17.107:E / AndroidRuntime(18174):在com.crazydog.splitwiser.Toolkit.oAuthTransaction(Toolkit.java:65)
05-17 21:51:17.107:E / AndroidRuntime(18174):在com.crazydog.splitwiser.LogIn.onResume(LogIn.java:116)
05-17 21:51:17.117:W / ActivityManager(714):强制整理活动com.crazydog.splitwiser / .login文件
05-17 21:51:17.117:W / ActivityManager(714):强制整理活动com.crazydog.splitwiser / .InitialSplash
05-17 21:51:17.618:W / ActivityManager(714):活动暂停超时ActivityRecord {40d040d0 U0 com.crazydog.splitwiser / .login文件}
 

解决方案

我有相同的问题, 和你一样我认为这足以增加

 编译文件(库/路标,commonshttp4-1.2.1.2.jar)
编译文件(库/路标核心 -  1.2.1.2.jar)
 

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

I've spent hours trying to get a library to work with my project in Android Studio, and I just can't figure it out.

Here's what my dependencies look like for my module

And my libraries:

I've even added

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

to my build.gradle. Without this, the app would not even compile.

At this stage, when I try to reference one of the libraries in code, the app crashes with a NoClassDefFoundError exception.

Something tells me this shouldn't be this hard - what am I overlooking?

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}

解决方案

I had the exact same problem, And like you i thought it's enough to add the

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

It all worked after i did a ./gradlew clean (I'm on a mac, so in your case, the equivalent.) You should do this command from the Terminal/Command prompt when you're located on the root of your project.