Firebase数据库没有找到类错误(NoClassDefFoundError)

时间:2021-10-07 20:15:32

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:

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

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

java.lang.NoClassDefFoundError:解析失败: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:

我已经尝试向proguard添加以下规则,但它没有帮助:

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

UPDATE:

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

经过大量研究后,我认为这个问题与启用multiDex有关。

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

Any ideas how to solve this?

任何想法如何解决这个问题?

1 个解决方案

#1


0  

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!

通过检查我的库的POM文件解决。我注意到POM文件中缺少firebase数据库依赖项,即使我已将其添加到我的build.gradle中,这意味着发布到bintray gradle任务出错了!

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

我修复了gradle任务,现在一切都很好。

#1


0  

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!

通过检查我的库的POM文件解决。我注意到POM文件中缺少firebase数据库依赖项,即使我已将其添加到我的build.gradle中,这意味着发布到bintray gradle任务出错了!

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

我修复了gradle任务,现在一切都很好。