Исключение групп в Gradle для компиляции общего ресурса Facebook не разрешает все конфликты - PullRequest
0 голосов
/ 06 сентября 2018

Я бы хотел добавить com.facebook.android:facebook-share:4.33.0 в мое приложение для Android. Я столкнулся с кучей ошибок, когда просто добавил implementation 'com.facebook.android:facebook-share:4.33.0' в файл build.gradle моего приложения. На этот вопрос были ответы, которые объяснили проблему, поэтому я обновил файл build.gradle моего приложения так:

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlinx-serialization'

apply plugin: 'kotlin-kapt'

android {
compileSdkVersion 26
defaultConfig {
    applicationId "uk.co.davechambers.pegboard"
    targetSdkVersion 26
    minSdkVersion 21
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    vectorDrawables.useSupportLibrary= true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

repositories {
google()
jcenter()
maven { url "https://kotlin.bintray.com/kotlinx" }
maven { url "http://jcenter.bintray.com"}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.1.0'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-vector-drawable:26.1.0'
implementation "org.jetbrains.anko:anko:$anko_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serialization_version"
implementation 'com.jakewharton.timber:timber:4.7.1'
implementation "org.jetbrains.anko:anko-sqlite:$anko_version"
implementation "android.arch.persistence.room:runtime:1.0.0"

implementation 'com.google.code.gson:gson:2.8.5'

compile ('com.facebook.android:facebook-share:4.33.0') {
    exclude group: 'com.android.support', module: 'support-v4'
    exclude group: 'com.android.support', module: 'support-annotations'
    exclude group: 'com.android.support', module: 'cardview-v7'
    exclude group: 'com.android.support', module: 'customtabs'
    exclude group: 'com.android.support', module: 'appcompat-v7'
    exclude group: 'com.android.support', module: 'design'
    exclude group: 'com.android.support', module: 'support-vector-drawable'
    exclude group: 'android.arch.lifecycle', module: 'runtime'
    exclude group: 'com.google.zxing', module: 'core'
}

kapt "androidx.lifecycle:lifecycle-compiler:2.0.0-alpha1"

kapt 'android.arch.persistence.room:compiler:1.0.0'

implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:0.22.5"
}

kotlin {
experimental {
    coroutines "enable"
}
}

androidExtensions {
experimental = true
}

И файл Project Level Gradle выглядит так (он не изменился):

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.2.30'
ext.anko_version = '0.10.5'
ext.serialization_version = '0.4.1'
repositories {
    google()
    jcenter()
    maven { url "https://kotlin.bintray.com/kotlinx" }
    maven { url "http://jcenter.bintray.com"}
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.3'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath "org.jetbrains.kotlinx:kotlinx-gradle-serialization-plugin:$serialization_version"

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

}

allprojects {
repositories {
    google()
    jcenter()
    mavenCentral()
}
}

apply plugin: 'kotlin'
apply plugin: 'kotlinx-serialization'

Большинство моих ошибок исчезло, но я все еще получаю следующие проблемы с com.android.support:support-annotations:27.0.2 и android.arch.lifecycle:runtime:1.0.3:

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:support-annotations:27.0.2.
Open File
Show Details


Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:support-annotations:27.0.2.
Open File
Show Details


Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve android.arch.lifecycle:runtime:1.0.3.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support:support-annotations:27.0.2.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support:support-annotations:27.0.2.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve android.arch.lifecycle:runtime:1.0.3.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support:support-annotations:27.0.2.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support:support-annotations:27.0.2.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve android.arch.lifecycle:runtime:1.0.3.
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.android.support:support-annotations:27.0.2.
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.android.support:support-annotations:27.0.2.
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve android.arch.lifecycle:runtime:1.0.3.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.support:support-annotations:27.0.2.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.support:support-annotations:27.0.2.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve android.arch.lifecycle:runtime:1.0.3.
Open File
Show Details

После сбоя синхронизации строка implementation 'com.android.support:appcompat-v7:26.1.0' выделяется красным цветом с сообщением All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.0.2, 26.1.0. Examples include com.android.support:support-compat:27.0.2 and com.android.support:animated-vector-drawable:26.1.0 Но, если я последую совету в , этот ответ и обновлю compileSdkVersion, targetSdkVersion и xx.26.1.0 до 27, 27 и xx.27.0.2 Я получаю еще больше ошибок:

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:27.0.2.

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:design:27.0.2.

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:support-vector-drawable:27.0.2.

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:support-annotations:27.0.2.

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:support-annotations:27.0.2.

Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:27.0.2.

Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support:design:27.0.2.

Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support:support-vector-drawable:27.0.2.

Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support:support-annotations:27.0.2.

Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support:support-annotations:27.0.2.

Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:27.0.2.

Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support:design:27.0.2.

Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support:support-vector-drawable:27.0.2.

Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.google.code.gson:gson:2.8.5.

Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support:support-annotations:27.0.2.

Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support:support-annotations:27.0.2.

Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.android.support:appcompat-v7:27.0.2.

Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.android.support:design:27.0.2.

Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.android.support:support-vector-drawable:27.0.2.

Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.android.support:support-annotations:27.0.2.

Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.android.support:support-annotations:27.0.2.

Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:27.0.2.

Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.support:design:27.0.2.

Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.support:support-vector-drawable:27.0.2.

Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.support:support-annotations:27.0.2.

Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.support:support-annotations:27.0.2.

Кто-нибудь может пролить свет на то, как я могу решить проблемы с оставшимися двумя зависимостями?

...