Search code examples
androidgradlescribe

Scribe not importing correctly using gradle in android studio


following the readme file on github:

I've added scribe to the dependency:

dependencies {
    classpath 'com.android.tools.build:gradle:0.4'
    classpath 'org.scribe:scribe:1.3.5'
}

The gradle build completes without errors but still i get errors:

Gradle: cannot find symbol class ServiceBuilder
Gradle: cannot find symbol class LinkedInApi
Gradle: cannot find symbol variable mRequestToken 
....

here is my build.gradle:

buildscript {
repositories {
    mavenCentral()
}
dependencies {
    classpath 'com.android.tools.build:gradle:0.4'
}
}

apply plugin: 'android'

repositories {
maven {
    credentials {
        id 'scribe-java-mvn-repo'
    }
    url "https://raw.github.com/fernandezpablo85/scribe-java/mvn-repo/"
}
}

dependencies {
compile files('libs/android-support-v4.jar')
compile 'org.scribe:scribe:1.3.5'
} 

Solution

  • Create a new dependencies clause outside of the buildscript clause that looks like:

    dependencies {
        compile 'org.scribe:scribe:1.3.5'
    }
    

    This is the dependencies clause for your code used by the java plugin.

    Also make sure you have the repositories clause outside of the buildscript:

    repositories {
       mavenCentral()
    }
    

    This is defines the repositories that will be searched for dependencies.

    Remove the classpath 'org.scribe:scribe:1.3.5' from your buildscript dependencies clause. This clause is used for the buildscript itself.

    Your new build.gradle file should look like:

    buildscript {
       repositories {
          mavenCentral()
       }
       dependencies {
          classpath 'com.android.tools.build:gradle:0.4'
       }
    }
    
    apply plugin: 'android'
    
    repositories {
       mavenCentral()
    }
    
    dependencies {
       compile files('libs/android-support-v4.jar')
       compile 'org.scribe:scribe:1.3.5'
    }