7 March 2015

How to solve problem with Failed to resolve: com.appbrain:appbrain-applift-sdk:+

Android Studio encourage us force to use Gradle.

If you didn't use Gradle before, then you will follow blindly, what AppBrain instructs you to setup project,but ....  If follow instruction from AppBrain and copy below part from "getting started"
repositories {
    maven {
        url 'http://swisscodemonkeys.github.io/appbrain-sdk/maven'
    }
}

dependencies {
    compile 'com.appbrain:appbrain-applift-sdk:+'
}

then it may sadly  throw an  error:
Failed to resolve: com.appbrain:appbrain-applift-sdk:+
Not good,but don't panic.. here is ..

SOLUTION:

Instead of what  AppBrain suggested,try code below:

buildscript {
    repositories {
        maven{
            url 'http://swisscodemonkeys.github.io/appbrain-sdk/maven'
        }
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.0'
        classpath 'com.appbrain:appbrain-applift-sdk:+'
    }
}

And You press sync now ...and it works!(It should at least :) ).

This example of  file build.gradle:

buildscript {
    repositories {
        maven{
            url 'http://swisscodemonkeys.github.io/appbrain-sdk/maven'
        }
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.0'
        classpath 'com.appbrain:appbrain-applift-sdk:+'
    }
}
apply plugin: 'com.android.application'

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile 'com.google.android.gms:play-services:6.5.87'

}

android {
    compileSdkVersion 21
    buildToolsVersion '20.0'

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        instrumentTest.setRoot('tests')
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}


I hope,it helps you.Take care folks and have fun!