2017-07-24 79 views
1

我试图连接SDK库添加到使用我的项目在这里提供的说明时:冲突与依赖“com.android.support::support-v4”添加连接SDK到摇篮文件

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

当我添加行“编译‘com.connectsdk:SDK-机器人连接-: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' 
} 
+0

你的'build.gradle'文件是什么? – Ninja

+0

@Ninja编辑我的帖子。 –

回答

0

Resolved versions for app (22.2.1) and test app (22.0.0) differ.

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