简体   繁体   English

从Android库项目引用的Jar未被App引用。 NoClassDefFoundError

[英]Jar referenced from android library project not referenced by App. NoClassDefFoundError

I have searched SO and tried all the solutions I came across but nothing seems to work. 我已经搜索过SO,并尝试了遇到的所有解决方案,但似乎没有任何效果。 The things I tried are the solutions given here , here , here , here and here but nothing seems to work. 我尝试过的事情是这里这里这里这里这里给出的解决方案,但似乎没有任何效果。

As described in some of those question I have a java library (lets say J) included in a android library (AL) that is included in a android app (AA). 如其中一些问题所述,我在一个Android应用程序(AA)中包含的一个Android库(AL)中包含了一个Java库(比方说J)。 I have added the library to the libs of both (have also tried with adding it to just AA and including in AL, and vice-versa and just in AL and expecting android dependencies to take care of it) but that or anything else did not work. 我已经将该库添加到两个库中(也尝试将其添加到AA中,包括在AL中,反之亦然,也仅添加到AL中,并期望android依赖项能够处理该库),但是那还是其他的都没有工作。

I am using the latest tools(version 20.0.3). 我正在使用最新的工具(版本20.0.3)。 The build android version for the android library and the app is 2.2 and min SDK is 5. android库和应用程序的构建android版本是2.2,最小SDK是5。

I can see the the java library in the android dependencies of the app but am getting a NoClassDefFoundException and run time. 我可以在应用程序的android依赖项中看到java库,但是正在获取NoClassDefFoundException和运行时。

How can I get this to work? 我该如何工作?

The android library must reference a jar, since that contains some encryption logic that I need to hide. android库必须引用一个jar,因为它包含一些我需要隐藏的加密逻辑。 The library is being created for distribution, the app is just something quite simple for testing the library. 该库是为分发而创建的,该应用程序只是测试库非常简单的事情。

There were 2 different but related problems causing this issue. 有两个不同但相关的问题导致此问题。

  1. The Java library, J was compiled with compliance level 1.7 (default for my system). Java库J的合规性级别为1.7(我的系统默认)。 This needs to be at 1.5, the compliance level of Android. 该值必须为Android的合规性水平1.5。 (compliance level may change in the future). (合规水平将来可能会更改)。
  2. The J library was also compiling using the J2SE library. J库也正在使用J2SE库进行编译。 I had to replace that with the anroid.jar of the same api level as my app. 我必须用与我的应用程序相同的api级别的anroid.jar替换它。

Then also things didn't work and for some reason it started working after I deleted the project and recreated in new directories.(IMP: take a code backup first). 然后,事情也没用,由于某种原因,在我删除项目并在新目录中重新创建之后,它开始起作用。(IMP:首先进行代码备份)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM