Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android studio importing in gradle issue

I am new to Android Studio and was just trying to import my eclipse project. i am trying to resolve this issue for quite a while now but unable to. I have a mainactivity project which uses mmany other libraries staggeredgridview, devsmart, google maps and appcompactv7. I am getting following 2 errors.

Note: mainactivity project is the one which i am working on and uses other external libraries.

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
    }
}
like image 273
gandharv09 Avatar asked Dec 31 '14 13:12

gandharv09


People also ask

How do I import into Gradle?

Launch Android Studio, and click File > New > Import Project. Locate your project directory, click the build. gradle file you created above to select it, and then click OK to import your project.

Why is my Gradle not syncing?

Resolution is simple. Open the "Android SDK Manager", update all packages and then restart your Android Studio. After that you project should compile without any issues.

Why is Gradle keeps downloading itself again and again with Android Studio?

Enable offline mode in Android Studio to disable checking for updates everytime. Go to Settings>Compiler>Gradle>Offline mode. If this is enabled the gradle will be told not to connect to internet and check for updates.


2 Answers

Just edit minsdk of your build.gradle of mainactivity to 9 :

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

Note : Also did the same for other libs if there minsdk is small then 9

like image 76
Cool Avatar answered Oct 19 '22 23:10

Cool


Please open your manifest file and write the bellow code it will work

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

and add the list of libraries for uses-skd separated by comma

like image 40
Prakash Madduri Avatar answered Oct 19 '22 23:10

Prakash Madduri