Android工作室导入gradle问题

时间:2014-12-31 13:57:24

标签: android gradle android-studio

我是 Android Studio 的新手,只是想导入我的eclipse项目。我现在试图解决这个问题很长一段时间但无法解决。 我有一个mainactivity项目,它使用mmany其他库 staggeredgridview,devsmart,google maps和appcompactv7 。我得到了2个错误。

注意:mainactivity项目是我正在处理并使用其他外部库的项目。

Error:(7, 5) uses-sdk:minSdkVersion 8 cannot be smaller than version 9 declared in library B:\Android Studio Projects\mainActivity\build\intermediates\exploded-aar\com.google.android.gms\play-services\6.5.87\AndroidManifest.xml 

Suggestion: use tools:overrideLibrary="com.google.android.gms" to force usage
:mainActivity:processDebugManifest FAILED
Error:Execution failed for task ':mainActivity:processDebugManifest'.
Manifest merger failed with multiple errors, see logs

build.gradle of mainactivity

apply plugin: 'com.android.application'

android {
compileSdkVersion 17
buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "com.example.staggeredgridviewdemo"
    minSdkVersion 8
    targetSdkVersion 16
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile project(':devsmartAndroid')
    compile project(':staggeredGridViewmaster')
    compile 'com.google.guava:guava:16.0.1'
    compile 'com.google.android.gms:play-services:+'
    compile 'com.android.support:appcompat-v7:19.1.0'
    compile files('libs/commons-codec-1.6.jar')
}

build.grade for devsmart

apply plugin: 'com.android.library'

android {
    compileSdkVersion 14
    buildToolsVersion "21.1.2"

    defaultConfig {
        minSdkVersion 4
        targetSdkVersion 4
    }

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile files('libs/CWAC-SackOfViewsAdapter.jar')
    compile('com.android.support:appcompat-v7:19.1.0') {
        // really use 19.1.0 even if something else resolves higher
       force = true
    }
}

build.gradle for sttageredgridview

apply plugin: 'com.android.library'

android {
    compileSdkVersion 17
    buildToolsVersion "21.1.2"

defaultConfig {
    minSdkVersion 8
    targetSdkVersion 16
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile('com.android.support:appcompat-v7:19.1.0') {
        // really use 19.1.0 even if something else resolves higher
       force = true
    }
}

3 个答案:

答案 0 :(得分:7)

只需将 build.gradle of mainactivity minsdk修改为9

defaultConfig {
    applicationId "com.example.staggeredgridviewdemo"
    minSdkVersion 9 // changed line
    targetSdkVersion 16
}

注意:如果minsdk小于9

,其他lib也一样

答案 1 :(得分:1)

请打开您的清单文件并写下它将起作用的波纹管代码

<uses-sdk tools:overrideLibrary="com.google.android.gms"/>

并添加用逗号

分隔的uses-skd的库列表

答案 2 :(得分:0)

转到所有项目的所有清单文件或build.gradle文件,并使minSDKversions相同。例如。