0

I'm using Square's Wire library for my Android app, using Android Studio with Gradle.

I originally added the wire-runtime-1.2.0.jar into a libs folder in my module, and added the dependency to Gradle like this in my build.gradle file:

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

That worked fine.

I'm new to Gradle and Android Studio, but based on the way I'm depending on the Google Support and Play Services libraries, I thought I might be able to remove the wire-runtime-1.2.0.jar library from my repository and just declare a dependency like this (the line is from the Maven repository):

dependencies {
    compile 'com.squareup.wire:wire:1.0.0'
}

But if I do that then I hit this error:

Gradle: package com.squareup.wire does not exist

Is there a way to set up this dependency without importing the JAR file directly? Or does that only work for libraries that you can install through the SDK Manager?

Charles
  • 50,943
  • 13
  • 104
  • 142
Dan J
  • 25,433
  • 17
  • 100
  • 173
  • I'm no expert at dependencies from Maven Central, but that sure looks like it should work. Note that Wire is up to 1.2.0, so you might wish to try that, or go with the `+` notation, or something. Also, the `wire-runtime` artifact, not the `wire` artifact, would appear to be the equivalent of the JAR you were using. And, do you have `mavenCentral()` in `repositories` in `buildscript`? – CommonsWare Nov 21 '13 at 19:51
  • I had tried 1.2.0 as well as 1.0.0, and I have `mavenCentral()` in my `buildscript` `repositories` section. ...but you are right about the artifact - it should be `wire-runtime` instead of `wire`. Please add that as the answer and I will accept it! – Dan J Nov 21 '13 at 20:05

1 Answers1

4

Some packages, like com.squareup.wire, have multiple artifacts in Maven Central. You need to choose the right one for your needs. In this case, the equivalent of wire-runtime-1.2.0.jar is the wire-runtime artifact, not the wire artifact.

Here's what your dependencies section should look like:

dependencies {
    compile 'com.squareup.wire:wire-runtime:1.2.0'
}
Dan J
  • 25,433
  • 17
  • 100
  • 173
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491