Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Android Lists and Adapters (2015) Lists with RecyclerViews Introducing RecyclerView

Niyamat Almass
Niyamat Almass
8,176 Points

What's wrong in my gradle?

I enter in my gradle

gradle.java
compile 'com.android.support:appcompat-v7:21.0.2' 
compile 'com.android.support:recyclerview-v7:21.0.2'

Ben Jakuben use same code what I entered but when syncing my gradle its gave my two error that cannot find compile 'com.android.support:appcompat-v7:21.0.2' cannot find compile 'com.android.support:recyclerview-v7:21.0.2'

I am using android studio(BETA) 0.8.2

I am also download android support library in sdk manager.

Can someone help me to figure out what's going wrong?

4 Answers

Andres Badilla
Andres Badilla
4,692 Points

Hi Niyamat Almass .

The same issue happened to me and this is what I did:

On the "build.gradle", add the recyclerview dependency as follows:

compile 'com.android.support:recyclerview-v7:21.0.+'

And then change the minSdkVersion and the targetSdkVersion fields on the same file (build.gradle) to 21 so it matches the version of recyclerview we are using:

minSdkVersion 21
targetSdkVersion 21

Finally remember to sync your gradle files and it should complete successfully.

NOTE If you are still getting this error after following these steps, rebuild your project by going to "Build" in the menu bar and the click on "Rebuild project"

Lee Reynolds Jr.
Lee Reynolds Jr.
5,160 Points

This worked for me. Thank you so much.

Ben Deitch
STAFF
Ben Deitch
Treehouse Teacher

Hey Niyamat! It looks like you have a different version of those than Ben Jakuben uses in the video. An easy way to find out what version you have installed is to quickly create a new project (just accept all the defaults) and then compare build.gradle files between the two projects. The new project should default in the correct version values and then you can copy those into your current project.

Niyamat Almass
Niyamat Almass
8,176 Points

Hi Ben Deitch I thought if I download the latest version of android it will be solved.So I download "Android Studio 1.3.2" But I got another issue.When I first open a new project in my new android studio the gradle gave me an error.

My gradle is

gradle.java
apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "20.0.0"

    defaultConfig {
        applicationId "com.example.niyamat.testing"
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.+'
}

And my error is

gradlebuild.java
minSdkVersion 14 cannot be different than version L declared in library

What's going wrong.I am really confused?

I searched over the internet but I don't get best solution for my problem.

Please help me?

zahir herz
zahir herz
3,513 Points

I'm using compileSdkVersion 23 had success using compile 'com.android.support:recyclerview-v7:+'

Abhinav Kanoria
Abhinav Kanoria
7,730 Points

Probably you should update your SDK. My gradle uses 23.3.0 version number. Maybe you should try using this.