Android工作室导入gradle问题

gan*_*v09 6 android gradle android-studio

我是Android Studio的新手,只是想尝试导入我的eclipse项目.我现在试图解决这个问题很长一段时间但无法解决.我有一个mainactivity项目,使用mmany其他库staggeredgridview,devsmart,谷歌地图和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
Run Code Online (Sandbox Code Playgroud)

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')
}
Run Code Online (Sandbox Code Playgroud)

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
    }
}
Run Code Online (Sandbox Code Playgroud)

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
    }
}
Run Code Online (Sandbox Code Playgroud)

Chu*_*ulo 7

只需minsdkmain.tivity的build.gradle编辑为9:

defaultConfig {
    applicationId "com.example.staggeredgridviewdemo"
    minSdkVersion 9 // changed line
    targetSdkVersion 16
}
Run Code Online (Sandbox Code Playgroud)

注意:如果minsdk小于9,那么对其他库也一样

  • 我认为,通过将minSdkVersion增加到9,app只能在API级别> = 9下工作,那么如何在不增加minSdkVersion的情况下解决这个问题呢? (3认同)