Firebase数据库找不到类错误(NoClassDefFoundError) [英] Firebase database no class found error (NoClassDefFoundError)

查看:42
本文介绍了Firebase数据库找不到类错误(NoClassDefFoundError)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用多个子模块的大型项目,我已将firebase数据库依赖项添加到项目中包含的我的一个模块中.在本地测试将模块包含为开放项目的地方时,一切正常,使用封闭模块(我的模块为aar文件提供)进行构建时,出现以下错误:

I have large project that uses multiple sub-modules, I have added the firebase database dependency to one of my modules that is included in my project. When testing locally where modules are included as open projects everything works fine, when building using closed modules (my modules come as aar files) I get the following error:

java.lang.NoClassDefFoundError:无法解决以下问题:Lcom/google/firebase/database/FirebaseDatabase;

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/database/FirebaseDatabase;

我的模块中包含以下依赖项:

I have include the following dependency in my module:

implementation 'com.google.firebase:firebase-database:11.0.4'

我已尝试添加以下规则以维护如下规则,但这无济于事:

I have tried adding to proguard the following rule but it's not helping:

-keep public class com.google.firebase.database.** {
    *;
}

更新:

经过大量研究,我认为此问题与启用multiDex有关.

After doing a lot of research, I think this issue is related to having multiDex enabled.

ClassNotFoundException: Didn't find class "com.google.firebase.database.FirebaseDatabase" on path: DexPathList

有什么办法解决这个问题吗?

Any ideas how to solve this?

推荐答案

通过检查库的POM文件解决了.我注意到即使将POM添加到我的build.gradle文件中,该文件也缺少了Firebase数据库依赖项,这意味着发布到Bintray gradle任务出了点问题!

Solved by checking the POM file of my library. I noticed that the firebase database dependency was missing from the POM file even though i have added it to my build.gradle, which means something went wrong with the publish to bintray gradle task!

我已经解决了gradle任务,现在一切正常.

I made a fix to the gradle task and now all good.

这篇关于Firebase数据库找不到类错误(NoClassDefFoundError)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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