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 The Options Menu

Colorizer: sync failed

I imported the project files that were included in the teacher's notes. The project fails to sync, and it gives the following error.

WARNING: The specified Android SDK Build Tools version (25.0.2) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.4.1. Android SDK Build Tools 28.0.3 will be used. To suppress this warning, remove "buildToolsVersion '25.0.2'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools. Remove Build Tools version and sync project Affected Modules: app

I tried to remove the buildToolsVersion line from the Gradle file. I also tried to update it to buildToolsVersion "28.0.3". Neither option has allowed the project to sync. Is there something else I can try?

3 Answers

Hi Eric

  • Just remove that buildToolsVersion line. Since Android Studio 3.0, it is no longer a requirement as the system selects the version for you (unless you want to use a different version than the default one).
  • Update your compileSdkVersion and targetSdkVersion to 28
  • Under dependencies, replace compile with implementation and update the dependencies versions there too (Android Studio will highlight the ones that need updating and tell you which version to use)
  • Follow Android Studio's instructions for anything else

Hope that helps :) Good luck!

Lauren,

Thanks for the help. It's getting me closer to where I want to be. Here is my build.gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.teamtreehouse.colorizer"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:appcompat-v7:28.0.3'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    implementation 'com.github.bumptech.glide:glide:3.7.0'
}

Here are the errors that I get:

ERROR: Failed to resolve: com.android.support:appcompat-v7:28.0.3
Add Google Maven repository and sync project
Show in Project Structure dialog
Affected Modules: app


ERROR: Failed to resolve: com.android.support.constraint:constraint-layout:1.1.3
Add Google Maven repository and sync project
Show in Project Structure dialog
Affected Modules: app


ERROR: Failed to resolve: com.android.support.test.espresso:espresso-core:2.2.2
Add Google Maven repository and sync project
Show in Project Structure dialog
Affected Modules: app

Ok. That's good. In your top-level build.gradle file (the other one), just add the google() repository, like this:

buildscript { 
    repositories {
        google() // here
        jcenter()
    }
    dependencies {
        // (...)
    }
}

allprojects {
    repositories {
        google() // and here
        jcenter()
    }
}

That should do it. That's what those Google Maven repository error logs are all about.

Adolfo Obregon
Adolfo Obregon
10,156 Points

I did all this but still didn't solved the problem. What solved the problem was changing the Gradle Version to 6.3. Go to File>Project Structure>Project>Gradle Version to 6.3 After that File>Invalidate and Restart

I have no more errors on AppCompatActivity.

David Lacho
David Lacho
20,864 Points

I managed to get the project running by changing my app file to:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.teamtreehouse.colorizer"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    implementation 'com.github.bumptech.glide:glide:3.7.0'
}

and my build.gradle file to:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Copy/Pasted David's code and changed the url in gradle-wrapper-properties to the most updated gradle distro and got it to build properly. Just wish I understood what I was doing with gradle better so I didn't just have to copy/paste to get these old project files to work. It'd be nice if treehouse actually updated things too.