7
votes

Google promotes their new Java Client library here: https://developers.google.com/appengine/docs/java/googlecloudstorageclient/

Note: I am not talking about the native REST library. I want to work with the Java Client Library.

On the website, Google does not specify the import directive for Gradle. For Maven, pom.xml looks like this:

<dependency>
    <groupId>com.google.appengine.tools</groupId>
    <artifactId>appengine-gcs-client</artifactId>
    <version>RELEASE</version>
</dependency>

When I change this to work with my Gradle project, it doesn't work:

dependencies {
    compile 'com.google.appengine.tools:appengine-gcs-client:RELEASE'
}

It finds the tools there, but the com.google.appengine.tools.cloudstorage cannot be resolved (it resolves tools, though).

What I did then: I removed the library and seached for "gcs" in the Android Studio dependencies dialog; and it finds and adds the following directive to build.gradle:

dependencies {
    compile 'com.google.appengine.tools:appengine-gcs-client:0.3.9@jar'
}

Same problem with that as before: tools is resolved, but not tools.cloudstorage.

  • What am I doing wrong? Where does the library live/which import statement will I need to add to Gradle?

I don't want to download the jar as I want my project to update jars automatically. mavenCentral() is set, and here is my full build.gradle file, just in case you need it:

apply plugin: 'java'

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.google.appengine.tools:appengine-gcs-client:0.3.9@jar'
    compile 'com.google.http-client:google-http-client-android:1.18.0-rc'
}

Any help appreciated, thanks!

1
Don't you get an error saying that appengine-gcs-client:RELEASE can't be resolved? AFAIK, Gradle doesn't support RELEASE (but it does support latest.release). What happens when you build from the command line? Also try to omit the @jar part.Peter Niederwieser
Thanks @Peter Niederwieser for looking into this. I could solve the problem simply by changing the version to 0.3.13. Changed it and worked immediately.Oliver Hausler
I changed it back to 0.3.9 for curiosity and now it's working there too. I realized Android Studio has some hick-ups frequently, when new dependencies are added. So probably it was one of those.Oliver Hausler
@user3642107 great to hear you solved your own question! Please write up your comment as an answer and accept it so that this questions is marked as resolved.Misha Brukman
I already did that, but Stackoverflow didn't let me as I just subscribed. "You can't answer your own questions on the same day because you have less than 10 point." (or similar). [I won't do the writeup again, sorry.]Oliver Hausler

1 Answers

4
votes

You can use the following to specify version 0.4.4 (the most recent as of 1/14/2015):

compile 'com.google.appengine.tools:appengine-gcs-client:0.4.4'

or specify the latest version with a plus sign:

compile 'com.google.appengine.tools:appengine-gcs-client:+'

Using the latter is the faster answer, but it may cause unintended compatibility issues in the future as updates are release.