Android工作室导入gradle问题

前端之家收集整理的这篇文章主要介绍了Android工作室导入gradle问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我是 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

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
    }
}

解决方法

只需将main.active的build.gradle的minsdk编辑为9:
defaultConfig {
    applicationId "com.example.staggeredgridviewdemo"
    minSdkVersion 9 // changed line
    targetSdkVersion 16
}

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

原文链接:https://www.f2er.com/android/308607.html

猜你在找的Android相关文章