[英]Firebase support library dependency conflict for instant apps
I'm trying to implement instant apps into a project that uses Firebase database. 我正在尝试将即时应用程序实现到使用Firebase数据库的项目中。 I'm targeting SDK version 27 , so the support libraries are on version 27.0.2 .
我的目标是SDK版本27 ,因此支持库的版本为27.0.2 。
Firebase database version is 11.8.0 and gms version is 3.1.0 . Firebase数据库版本为11.8.0 , gms版本为3.1.0 。 When I try to sync, I get the following error:
当我尝试同步时,我收到以下错误:
Android dependency 'com.android.support:support-v4' has different
version for the compile (25.2.0) and runtime (27.0.2) classpath. You
should manually set the same version via DependencyResolution
I was able to get around the issue by adding the following dependencies explicitly before the instant apps 通过在即时应用程序之前显式添加以下依赖项,我能够解决此问题
implementation 'com.android.support:support-v4:27.0.2'
implementation 'com.android.support:support-media-compat:27.0.2'
But with the instant apps, even if I have them in the feature module (app-base), when I try to build the actual app (com.android.application), I again get the same error. 但是对于即时应用程序,即使我在功能模块(app-base)中有它们,当我尝试构建实际应用程序(com.android.application)时,我再次得到相同的错误。
I can again move around the issue by moving those conflicting dependencies into application module gradle file, in which case the sync succeeds, but then I'm facing another problem, this time with manifest merging, which prevents the app from finding the launcher activity: 我可以通过将这些冲突的依赖项移动到应用程序模块gradle文件中来解决这个问题,在这种情况下,同步成功,但是我面临另一个问题,这次是使用清单合并,这会阻止应用程序查找启动器活动:
Attribute provider#com.google.firebase.provider.FirebaseInitProvider@authorities value=(com.iamkaan.packagename.firebaseinitprovider) from AndroidManifest.xml:10:13-72 is also present at AndroidManifest.xml:33:350-423 value=(com.iamkaan.packagename.base.firebaseinitprovider).
来自AndroidManifest.xml的属性提供者#com.google.firebase.provider.FirebaseInitProvider@authorities value =(com.iamkaan.packagename.firebaseinitprovider):AndroidManifest.xml中还有10:13-72:33:350-423 value = (com.iamkaan.packagename.base.firebaseinitprovider)。 Suggestion: add 'tools:replace="android:authorities"' to element at AndroidManifest.xml:8:9-12:39 to override.
建议:在AndroidManifest.xml:8:9-12:39中添加'tools:replace =“android:authorities”'来覆盖。 app main manifest (this file), line 9
app主要清单(此文件),第9行
This last issue is somehow related to firebase-core
dependency because when I changed my app gradle dependencies from 最后一个问题以某种方式与
firebase-core
依赖关系有关,因为当我更改我的应用程序gradle依赖关系时
implementation project(':app-base')
to 至
implementation (project(':app-base')) {
exclude group: 'com.google.firebase', module:'firebase-core'
}
I was able to run the app. 我能够运行该应用程序。 But this time, I started getting the following error on runtime (the first time I call
FirebaseDatabase.getInstance()
) 但这一次,我开始在运行时收到以下错误(我第一次调用
FirebaseDatabase.getInstance()
)
Default FirebaseApp is not initialized in this process com.iamkaan.packagename. Make sure to call FirebaseApp.initializeApp(Context) first
It was indeed not called but was working without anyway until instant app implementation. 它确实没有被调用,但是直到应用程序即时实施才开始工作。 Anyway, I added the call to various places before the first FirebaseDatabase call, nothing helped.
无论如何,我在第一次FirebaseDatabase调用之前将调用添加到了各个地方,没有任何帮助。
Package names 包名称
com.iamkaan.packagename
com.iamkaan.packagename
com.iamkaan.packagename
com.iamkaan.packagename
com.iamkaan.packagename.base
com.iamkaan.packagename.base
I ran into something similar and it is caused by support libraries being included by dependencies. 我碰到了类似的东西,它是由依赖项包含的支持库引起的。 It's important to note that almost all of Google/Android support libraries (CardView, RecyclerView etc) includes the latest v4 and v7 support libraries.
值得注意的是,几乎所有Google / Android支持库(CardView,RecyclerView等)都包含最新的v4和v7支持库。 So that usually causes conflicts.
所以这通常会导致冲突。
What you need to do is: 你需要做的是:
implementation project(':app-base')
only implementation project(':app-base')
api
instead of implementation
for support libs included inside Base Module's build.gradle
ie api 'com.android.support:support-v4:27.0.2'
api
而不是implementation
基础模块的build.gradle
包含的支持库,即build.gradle
api 'com.android.support:support-v4:27.0.2'
build.gradle
file build.gradle
文件中 build.gradle
file, exclude support libs FOR EACH item (see example below) build.gradle
文件,请排除FOR EACH项目的支持库(请参阅下面的示例) api('com.android.support:support-media-compat:27.0.2') {
exclude group: 'com.android.support'
}
api('com.android.support:support-v7:27.0.2') {
exclude group: 'com.android.support'
}
I will also recommend not using com.android.support:support-v7:27.0.2
instead use only the specific items from support libs that you need. 我还建议不要使用
com.android.support:support-v7:27.0.2
而只使用您需要的支持库中的特定项。 See Support Library Packages on how can you add only specific items from support libs. 请参阅支持库包 ,了解如何仅添加支持库中的特定项。
try this. 试试这个。 SDK is 28
SDK是28
implementation ('com.google.firebase:firebase-core:16.0.6'){
exclude module: 'support-media-compat'
exclude module: 'support-v4'
}
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:support-media-compat:28.0.0'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.