我搜索了一个解决方案,并在堆栈溢出方面找到了其他答案(例如solution 1)来解决此错误。
这是我的build.gradle
optimize table
但是每次我尝试编译时都会出现错误:
库com.google.android.gms:play-services-measurement-base是 由[[15.0.4,15.0.4]]的其他各种图书馆要求, [16.0.2,16.0.2]],但解析为16.0.2。禁用插件并检查 您的依赖树使用./gradlew:app:dependencies。
这是我的顶级build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
signingConfigs {
}
compileSdkVersion 27
buildToolsVersion '27.0.3'
useLibrary 'org.apache.http.legacy'
buildTypes {
...
}
}
dependencies {
implementation files('libs/jsoup-1.8.1.jar')
implementation files('libs/org.apache.http.legacy.jar')
implementation files('libs/opencsv-3.8.jar')
implementation 'com.google.firebase:firebase-database:16.0.2'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.firebase:firebase-config:16.0.0'
implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.google.firebase:firebase-messaging:17.3.2'
implementation 'com.firebaseui:firebase-ui-database:3.2.1'
implementation 'com.google.android.gms:play-services-analytics:16.0.3'
implementation 'com.google.android.gms:play-services-ads:15.0.1'
implementation 'com.google.android.gms:play-services-auth:16.0.0'
implementation "com.android.support:design:27.1.1"
implementation "com.android.support:customtabs:27.1.1"
implementation "com.android.support:cardview-v7:27.1.1"
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:preference-v7:27.1.1'
implementation 'com.github.bumptech.glide:glide:4.7.1'
implementation('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
transitive = true
}
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.installreferrer:installreferrer:1.0'
}
apply plugin: 'com.google.gms.google-services'
我刚刚将所有依赖项更新到最新版本,并且我不知道如何构建我的项目。
谢谢!
答案 0 :(得分:0)
我刚发现依赖项排序很重要...现在我放上
implementation 'com.google.firebase:firebase-core:16.0.3'
在顶部,我没有任何构建问题!
这是我的构建gradle:
dependencies {
implementation files('libs/jsoup-1.8.1.jar')
implementation files('libs/org.apache.http.legacy.jar')
implementation files('libs/opencsv-3.8.jar')
implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.google.firebase:firebase-database:16.0.2'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.firebase:firebase-config:16.0.0'
implementation 'com.google.firebase:firebase-messaging:17.3.2'
implementation 'com.firebaseui:firebase-ui-database:3.2.1'
implementation 'com.google.android.gms:play-services-analytics:16.0.3'
implementation 'com.google.android.gms:play-services-ads:15.0.1'
implementation 'com.google.android.gms:play-services-auth:16.0.0'
implementation "com.android.support:design:27.1.1"
implementation "com.android.support:customtabs:27.1.1"
implementation "com.android.support:cardview-v7:27.1.1"
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:preference-v7:27.1.1'
implementation 'com.github.bumptech.glide:glide:4.7.1'
implementation('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
transitive = true
}
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.installreferrer:installreferrer:1.0'
}
答案 1 :(得分:0)
为解决此问题,我遵循了Google Firebase集成准则,并对我的app / build.gradle和project / build.gradle进行了以下更改
如有任何疑问,请点击此链接
https://firebase.google.com/docs/android/setup
app / build.gradle
中的更改
implementation (project(':react-native-firebase')) {
transitive = false
}
implementation 'com.google.android.gms:play-services-base:15.0.2'
implementation "com.google.firebase:firebase-core:16.0.1"
implementation "com.google.firebase:firebase-messaging:17.4.0"
project / build.gradle
中的更改
repositories {
google()
jcenter()
mavenCentral()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
//Below line of code should be latest if you are using firebase version 16.0 +
classpath 'com.google.gms:google-services:4.2.0'// below google-services plugin
}
allprojects {
repositories {
google()// add it to top instead of bottom or somewhere in middle
mavenLocal()
mavenCentral()
maven {
url 'https://maven.google.com'
}
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}