在NoClassDefFoundError的运行在Android的Studio中.AAR类 [英] NoClassDefFoundError at Runtime on class inside .AAR in Android Studio

查看:2346
本文介绍了在NoClassDefFoundError的运行在Android的Studio中.AAR类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在研究有关可能解决这个但无论我尝试的,只不过没有几个小时。这里的解释情况:

I've been researching for many hours about a possible solution to this but whatever I try it just fails. Here's the explained situation:

我对Android的工作室这个库项目产生的 APP-debug.aar 文件。
然后,我在项目实施添加这个新的模块,跟随向导导入.JAR / .AARs我挑 .aar 和更新的依赖:应用程序在项目结构

I have this library project on Android Studio which generates the app-debug.aar file. Then I add this new module in the implementing project, following the wizard to import .JAR/.AARs I pick the .aar and update the dependency for :app in the Project Structure.

一旦项目清理(即使使用 ./ gradlew干净 - Mac OS X的),我可以在任何活动和这个类的引用它的方法。

Once the project is cleaned (even using ./gradlew clean--Mac OS X) I can make references of this class and its methods in any of the activities.

现在在运行时,一旦建成并安装在实际设备应用程序会崩溃抛出上述运行时异常。

Now at runtime, once built and installed on the real devices the app will crash throwing the aforementioned Runtime Exception.

请注意:我在导入 .aar ,因为我需要保护code,它有资源,一个的.jar 是出了问题。如果我导入库模块(带有源和所有,而不是一个 .aar ),那么应用程序有没有问题,在运行时。

Note: I'm importing the .aar because I would need to protect the code and it has resources so a .jar is out of the question. And if I import the library module (with source and all instead of an.aar) then the app has no issues at runtime.

我用尽了一切。如果任何人都可以扔什么,这可能是一些轻,这将是非常美联社preciated。

I've tried everything and if anyone can throw some light on what this could be, it'll be highly appreciated.

该类扩展的ViewGroup ,并在运行的情况下暗示任何被实例化。在code是给我,所以,除非它是绝对必要的重大变化可能是不可能的。

The class extends ViewGroup and is instantiated at runtime in case that implies anything. The code was given to me so major changes might not be possible unless it's absolutely necessary.

由于事先给大家!

阿曼多

推荐答案

NoClassDefFound 错误实际上已经发生在一个向后兼容库正在使用这个类我提到的问题(A类)。没有给出细节高于A类其他找不到,后来发现,另一个类也有类似的问题,但在使用相同的例外是compat的LIB指着我注意到A类也调用其方法和执行其回调。通过颠簸了分钟版本(使用本机API)我可以克服这个问题。这的确是包括在 .aar 或者看起来是这样的向后压缩库的问题。我应该明白这个问题好了很多,我会更新这个答案。

The NoClassDefFound error has actually happening to a backward-compatibility library being used by this class I mentioned on the question ("Class A"). No details were given other than Class A couldn't be found and later on found out that another class had a similar issue BUT was pointing at that compat lib with the same exception and I noticed that Class A was also calling its methods and implementing its callbacks. By bumping up the min version (to use the native API) I could overcome that issue. It was indeed a problem of including that backward-comp library in the .aar or so it seems. Should I understand this issue a lot better I'll update this "answer."

这篇关于在NoClassDefFoundError的运行在Android的Studio中.AAR类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆