与依赖的冲突&com.android.support :: support-v4'将Connect SDK添加到gradle文件时

时间:2017-07-24 14:28:32

标签: android live-connect-sdk

我正在尝试使用此处提供的说明将Connect SDK库添加到我的项目中:

http://www.svlconnectsdk.com/docs/1-6-0/android/setup/

当我添加行' compile' com.connectsdk:connect-sdk-android:1.6.0'到我的build.gradle文件,它给了我以下错误:

Warning:Conflict with dependency 'com.android.support:support-v4'. Resolved versions for app (22.2.1) and test app (22.0.0) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
/home/jdave/workspace/main/Clients/Android/OEM/Fling/build/intermediates/res/merged/myCatapulTVe/debug/values/values.xml
Error:(232) Attribute "textAllCaps" has already been defined
Error:(269) Attribute "theme" has already been defined
Error:(232) Attribute "textAllCaps" has already been defined
Error:(269) Attribute "theme" has already been defined
Error:Execution failed for task ':processMyCatapulTVeDebugResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt

我该如何解决这个问题?

修改

这是我的gradle文件:

/**
 * versionName Android Manifest Version Name
 * @return read from -P and returns it or default
 */
def getVersionName() {
    def version = "1.0.0"
    if (hasProperty('app_version')) {
        version = project.app_version
    }
    return version
}

def hasDexguard() {
    def enable_dexguard = 'false'
    if (hasProperty('enable_dexguard')) {
        enable_dexguard = project.enable_dexguard
    }
    return enable_dexguard == 'true'
}
/**
 * versionCode Android Manifest Version Code
 * @return read from -P and returns it or default
 */
def getVersionCode() {
    def versionBuild = 0
    if (hasProperty('app_version_build')) {
        versionBuild = project.app_version_build
    }
    return versionBuild as int
}

project.ext {
    compileSdkVersion = 21
    buildToolsVersion = "22.0.1"
    versionName = getVersionName()
    versionCode = getVersionCode()
    minSdkVersion = 16
    targetSdkVersion = 21
    lintOptionsAbortOnError = false
    lintOptionsHtmlReport = false
}

buildscript {
    repositories {
        mavenCentral()
        maven {
            url "https://plugins.gradle.org/m2/"
            flatDir { dirs '../../components/java/DexGuard-7.0.20/lib' }
        }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        classpath ':dexguard:'
    }
}

apply plugin: 'com.android.application'
if(hasDexguard()){
    apply plugin: 'dexguard'
}

repositories {
    flatDir {
        dirs '../../../components/java/android-support/libs'
    }
    mavenLocal()
    mavenCentral()
}


println "hasDexguard:" + hasDexguard()
//if (hasDexguard()) {
//    apply plugin: 'dexguard'
//}
project.archivesBaseName = "app";
allprojects {
    android {
        compileSdkVersion project.rootProject.ext.compileSdkVersion
        buildToolsVersion project.rootProject.ext.buildToolsVersion
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_7
            targetCompatibility JavaVersion.VERSION_1_7
        }
    }
}
android {
    jacoco {
        version = "0.7.1.201405082137"
    }
    lintOptions {
        abortOnError = project.ext.lintOptionsAbortOnError
        disable 'RtlHardcoded',
                'RtlCompat',
                'RtlEnabled',
                'TypographyFractions',
                'TypographyQuotes'
        htmlReport false
        checkReleaseBuilds true
        fatal 'NewApi', 'InlineApi'
        error 'Wakelock', 'TextViewEdits'
        warning 'ResourceAsColor'
    }
    defaultConfig {
        minSdkVersion project.ext.minSdkVersion
        targetSdkVersion project.ext.targetSdkVersion
        testHandleProfiling true
        testFunctionalTest true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        versionName project.ext.versionName
        versionCode project.ext.versionCode
        multiDexEnabled true
    }
    signingConfigs {
        moregaSigningConfig {
            storeFile file("PrivateKey/Android_Private_Key")
            storePassword "111111"
            keyAlias "morega"
            keyPassword "111111"
        }
    }
    sourceSets {
        test {
            java.srcDirs = ['src/test']
        }
    }

    buildTypes {
        release {
            debuggable false
            minifyEnabled true
            shrinkResources true
//            signingConfig signingConfigs.moregaSigningConfig
            if (hasDexguard()) {
                proguardFile getDefaultDexGuardFile('dexguard-release.pro')
                proguardFile 'dexguard-project.txt'
            } else {
                proguardFile getDefaultProguardFile('proguard-android.txt')
                proguardFile 'dexguard-project.txt'
            }
            testCoverageEnabled = false
        }
        debug {
            debuggable true
            minifyEnabled false
            shrinkResources false
            versionNameSuffix '-DEBUG'
            testCoverageEnabled = false
//            signingConfig signingConfigs.moregaSigningConfig
            if (hasDexguard()) {
                proguardFile getDefaultDexGuardFile('dexguard-debug.pro')
                proguardFile 'dexguard-project.txt'
            } else {
                proguardFile getDefaultProguardFile('proguard-android.txt')
                proguardFile 'dexguard-project.txt'
            }
        }
    }

    /**
     * this is exactly what was missing for DirecTv projects and Adara projects
     * It is split configurations
     * we do branding in one configuration and backend into other as a result we will ahve a mix of all configs
     * for example if we have brand and config then we will have the brand-config-buildtype.apk variants
     */

    flavorDimensions "brand"
    productFlavors {

        /**
         * flavorDimention defines folders android plugin looking into
         * for example to build adara s2 the set of folders is the following
         * main
         * adara
         * s2
         * adaraS2
         *
         * if folder is missing it will be skipped and it is not an error
         * other properties for flavor
         * applicationId "com.buildsystemexample.app.demo"
         * versionName "1.0-demo"
         *
         * eventually we are trying to build not a flavor but build variant
         * Build Type + Product Flavor or/and dimention flavors = Build Variant
         */
        myCatapulTVe {
            applicationId "com.adara.mycatapultve"
            dimension "brand"
        }
    }

    packagingOptions {
        exclude 'LICENSE.txt'
    }
}

task listJars << {
    println "java jar config"
    configurations.compile.each { File file -> println file.name }
    println "test jar config"
    configurations.testCompile.each { File file -> println file.name }
}

subprojects {
    configurations {
        provided
    }

    dependencies {
        provided fileTree(dir: '../../../external/commonlibs/annotations', include: '*.jar')
    }
    android.applicationVariants.each { variant ->
        variant.javaCompile.classpath += configurations.provided
    }
    repositories {
        mavenCentral()
    }
    apply plugin: 'com.android.library'
    android {
        lintOptions {
            abortOnError = project.rootProject.ext.lintOptionsAbortOnError
            htmlReport = project.rootProject.ext.lintOptionsHtmlReport
            disable 'RtlHardcoded',
                    'RtlCompat',
                    'RtlEnabled',
                    'TypographyFractions',
                    'TypographyQuotes'
            fatal 'NewApi', 'InlineApi'
            error 'Wakelock', 'TextViewEdits'
        }


        packagingOptions {
            exclude 'LICENSE.txt'
        }
    }
    apply plugin: 'findbugs'

    task customFindbugs(type: FindBugs) {
        ignoreFailures = true
        effort = "max"
        reportLevel = "medium"
        classes = files("$project.buildDir/intermediates/classes")
        //Use this only if you want exclude some errors
        excludeFilter = file("$rootProject.rootDir/findbugs_exclude.xml")

        source = fileTree('src/main/java/')
        classpath = files()
        reports {
            xml.enabled = true
            xml.withMessages = true
            html.enabled = !xml.isEnabled()
            xml.destination "$project.buildDir/outputs/findbugs/findbugs-output.xml"
            html.destination "$project.buildDir/outputs/findbugs/findbugs-output.html"
        }
    }

    apply plugin: 'maven-publish'
    def coreAarFile = file('build/outputs/aar/'+project.name+'-release.aar')
    publishing {
        publications {
            maven(MavenPublication) {
                artifact source: coreAarFile,  extension:"aar"

                pom{
                    packaging ='aar'
                    version = "1.0"
                    groupId = 'com.morega.fling'
                    artifactId = project.name
                }
            }
        }
    }
    build.dependsOn customFindbugs

}

dependencies {
    compile files('../../external/commonlibs/json/json-io-2.6.0.jar')
    compile fileTree(dir: '../../external/commonlibs/annotations', include: '*.jar')
    compile fileTree(include: '*.jar', dir: 'src/main/libs')
    compile project(':common')
    compile project(':common_ui')
    compile project(':android-google-play-services_lib-v22')
    compile project(':android-CastCompanionLibrary-v22')
    compile project(':adara-middleware')
    compile project(':android-support')
    compile project(':android-mediarouter')
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.4'
    compile 'com.connectsdk:connect-sdk-android:1.6.0'
    testCompile fileTree(dir: '../../external/testlibs', include: '*.jar')

    androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.1'
    androidTestCompile 'com.android.support.test:rules:0.2'
}

1 个答案:

答案 0 :(得分:0)

  

应用(22.2.1)测试应用(22.0.0)的已解决版本不同。

确保您使用的是支持库的单一版本。 确定冲突的最简单方法是androidDependencies提供的Android plugin for Gradle任务。它将为每个构建变体和测试源集生成一个依赖关系树,其中包括项目的直接和传递依赖关系。