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 trialRussell Milburn
7,255 PointsGradle project sync failed
Gradle project sync failed
Taylor Bryant
7,395 PointsYou might be experiencing the same problem as I am since the new androids release. I used the SDK manager to download the latest stable sdk (Which was 25 at the time) and set that as my compile and target sdk inside the build.gradle (Module:App) file. Now after you change that the palette and recycler view dependencies will be throwing an error, This is because their 'Major' number needs to be the same as the compileSdkVersion, and the other 2 version numbers need to not exceed the latest version. Sync the project with your compile version and then 2 0's afterwards (25.0.0 for example) and the IDE will recommend the correct version. If you do not download the newest sdk from the sdk manager you will get an error asking you to install these versions from a repo. THEN you need to visit https://github.com/JakeWharton/butterknife and find out the correct import lines for the butterknife api that needs to be in your gradle files, and last but not least, you need to change the annotation of @Bind to @BindView for every butterknife binding, also change the imports within those java classes to import butterknife.bindview
Below are the examples of all of this
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.jimulabs.googlemusicmock"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
disable 'InvalidPackage'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
//Dependencies that needed to be changed
compile 'com.android.support:recyclerview-v7:25.1.0'
compile 'com.jakewharton:butterknife:8.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
compile 'com.android.support:palette-v7:25.1.0'
compile 'com.jimulabs.mirrorsandbox:mirror-sandbox:0.2.1'
}
The GitHub documentation also told me to add a line to the Project gradle file as well
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
//Line that was required to be added by butterknife
classpath 'com.jakewharton:butterknife-gradle-plugin:8.4.0'
}
}
allprojects {
repositories {
jcenter()
}
}
Your version numbers WILL be different, so if this doesn't work for you then you will need to read the error messages provided by the IDE to find out what is wrong
3 Answers
Gnani Pasupula
3,915 PointsRestart the project it will work
Juan Ferr
13,220 PointsClean and Rebuild the project.....if it's failing for the SDK version lower the min SDK in the build.gradle Module from 24 to 23
Darnell Cephus
4,208 PointsTo anyone having trouble using a physical device like me, I have android sdk 16 on my cell. (my emulator never works)
As of Oct 2016 update your gradle project file classpath to 'com.android.tools.build:gradle:2.2.1' then sync
then go to gradle module:app and input in minSdkVersion 15 then sync
it might say building for a long time, if it does this too long just restart your computer and open Android Studio again and everything should work fine.
15 is the minimum version supported by default as of Oct 2016....but now the app runs fine on my mobile device.
Hope that helps the emulator-less like me haha.
Seth Kroger
56,413 PointsSeth Kroger
56,413 PointsIf you check the Messages tab there should be a more descriptive message explaining why it failed.