aseolin
aseolin

Reputation: 1200

Adding a Maven dependency (XML) on a Android Studio project

I'm trying to use this Java library in my Android app. From the documentation, I have to put compile "json-to-pdf:json-to-pdf:0.7.5" in my build.grade dependencies. When I try to sync the project, I get an error:

Error:(39, 13) Failed to resolve: json-to-pdf:json-to-pdf:0.7.5

I asked the owner, but he does not know how to fix it. I think I have to add the following Maven dependencies in build.grade too:

<repositories>
  <repository>
    <id>clojars.org</id>
    <url>http://clojars.org/repo</url>
  </repository>
</repositories>

But I dont't know how to do that.

Here is my settings so far:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"
    compileOptions.encoding = 'ISO-8859-1'

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

repositories {
    jcenter()
    //mavenCentral() I tried that but doesn't work
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.1'
    ...
    compile 'json-to-pdf:json-to-pdf:0.7.5' // Doesn't work
}

Upvotes: 1

Views: 2523

Answers (1)

Mark Vieira
Mark Vieira

Reputation: 13486

You have to define the clojars Maven repository in your build.gradle.

repositories {
    jcenter()
    maven {
        url 'http://clojars.org/repo'
    }
}

The author of this library should probably add this to the GitHub readme.

Update: I responded to the GitHub issue with the appropriate Gradle snippet that should be added to the docs.

Upvotes: 1

Related Questions