Question

Is there an easy way to use the output from the gradle task appengineEndpointsGetClientLibs?

I use Android Studio to develop an application with multiple endpoints. When running "appengineEndpointsGetClientLibs" from the gradle window, the task runs successfuly. I can see the output in the build folder, but can't seem to find a way to actually use the output directly. Right now I'm unzipping and manually copy-pasting the classes into my project every time :(. Issn't there another way?

Was it helpful?

Solution

With the appengine-gradle-plugin-1.9.4 there are a few ways to do it.

1: Using the endpoints artifact (this is new) in your project. This requires the appengine project to be part of your android project by specifying it in your settings.gradle file appropriately (http://www.gradle.org/docs/current/userguide/multi_project_builds.html). You can then reference the endpoints artifact from your android project by adding a compile dependency to the build.gradle file (path is a gradle project path, not a file path)

dependencies {
    compile project(path: '<appengine-module>', configuration: 'android-endpoints')  
}

This will include the endpoints client libraries and their dependencies.

2: appengineEndpointsInstallClientLibs (installs to local maven repo) which you can then reference in your build file.

3: appengineEndpointsExportClientLibs while I wouldn't recommend this, if you really wanted to export jar files to a location this would do it.

If you haven't seen the github page, it's worth taking a look to see what you might be able to do : https://github.com/GoogleCloudPlatform/gradle-appengine-plugin

OTHER TIPS

Use appengineEndpointsInstallClientLibs (This generate a readme.html too with instructions on how to use the output.)

This will install the libs to your local maven repository. To use them, follow th readme file :)

Step 1: Add the following compile section to your build.gradle file.

compile ([group: '#your.package.name#', name: '#endpointname#', version: '#endpointversion#'])

Step 2: Add one of the following compile sections to your build.gradle file, based on your platform (Android/App Engine/Servlet). Google Cloud Endpoints API client is compatible with all supported Java platforms (with minimum Java version 5).

For Android

compile ([group: 'com.google.api-client', name: 'google-api-client-android', version: '1.18.0-rc'])

For App Engine

compile ([group: 'com.google.api-client', name: 'google-api-client-appengine', version: '1.18.0-rc'])

For Java Servlet

compile ([group: 'com.google.api-client', name: 'google-api-client-servlet', version: '1.18.0-rc'])

Step 3: Add one of the following compile sections to your build.gradle file, or directly import AndroidJsonFactory into your Java source, based on your JsonFactory implementation (GSON/Jackson/AndroidJson).

Using GsonFactory

compile ([group: 'com.google.api-client', name: 'google-http-client-gson', version: '1.18.0-rc'])

Using JacksonFactory

compile ([group: 'com.google.api-client', name: 'google-http-client-jackson2', version: '1.18.0-rc'])

Using AndroidJsonFactory (Android with minimum API level 11) For Andoird with minimum API level 11, import AndroidJsonFactory into your Java source.

import com.google.api.client.extensions.android.json.AndroidJsonFactory;

Step 4: Make sure local Maven repository is added to the repository section of build.gradle file.

repositories { mavenCentral() mavenLocal() }

Step 5: Refer to the "Creating the service object" and "Calling the API exposed by the Endpoint" sections of this Endpoints Java Documentation to see how to use the client library in Android.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top