Can't build Couchbase-Lite for Android using gradle

I’ve followed the “getting started” page, but the gradle fails to sync.
Getting “Error:Failed to find: com.couchbase.lite:couchbase-lite-android:1.0.3”

Here’s my app gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

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

// CouchBase:
// workaround for "duplicate files during packaging of APK" issue
// see https://groups.google.com/d/msg/adt-dev/bl5Rc4Szpzg/wC8cylTWuIEJ
packagingOptions {
    exclude 'META-INF/ASL2.0'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/DEPENDENCIES' // Apache
}
}

repositories {
   mavenCentral()
   maven {
       url 'https://oss.sonatype.org/content/repositories/snapshots'
   }
}



dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')

/* Lollipop Support */
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:recyclerview-v7:+'

compile 'com.couchbase.lite:couchbase-lite-android:1.0.3' // CouchBase

compile 'com.googlecode.libphonenumber:libphonenumber:6.1' // LibPhoneNumber
compile 'com.google.code.gson:gson:2.2.4' // Gson
compile 'com.squareup.picasso:picasso:2.4.0' // Picasso
compile project(':asmack-android-8-4.0.6') // aSmack
compile 'com.soundcloud.android:android-crop:0.9.10@aar' // Image Crop

/* OkHttp */
compile 'com.squareup.okhttp:okhttp:2.2.0'
compile project(':okhttp-urlconnection-2.0.0')

/* Apache */
compile 'org.apache.httpcomponents:httpmime:4.3.6'
compile 'org.apache.httpcomponents:httpcore:4.4'

}

And this is my top-level gradle:

buildscript {
repositories {
    jcenter()
}

repositories {
    mavenCentral()
    maven {
        url "http://files.couchbase.com/maven2/"
    }
}

dependencies {
    classpath 'com.android.tools.build:gradle:1.0.0'
}
}

allprojects {
    repositories {
        jcenter()
    }
}

Any idea?
Thanks,
Aviv

I just tried it and it worked – what error are you getting?

Also can you switch to ‘com.couchbase.lite:couchbase-lite-android:1.0.4’? It’s about to be officially released soon.

Getting "Error:Failed to find: com.couchbase.lite:couchbase-lite-android:1.0.4"
Is there somewhere else I should look for the problem?

Hi @avivbs

Can you try to put “couchbase Maven repository” in allprojects section in top level build.gradle?

Top Level: build.gradle

// 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:1.0.0'

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

allprojects {
    repositories {
        jcenter()

        // couchbase Maven repository
        maven {
            url "http://files.couchbase.com/maven2/"
        }
    }
}

Check Hideki’s message below.

Also, when I said “it works for me”, I forgot to mention that I was using the TodoLite-Android example app.

Hi, @hideki solution worked!

Thank you both.

I was having this same problem when adding Couchbase into my project. I moved my project level repository code to the allprojects section as @hideki suggested and the project finally downloaded jars and built the project. Thanks!