Search code examples
androidgoogle-app-engineandroid-studiojdogoogle-cloud-endpoints

Generate Google Endpoints library (JDO) with Android Studio


I am trying to generate an JDO based endpoint from Android Studio, but the library is not being generated (and no error is shown). The only warning I can see is the one below regarding the annotations.

This is my gradle log:

:app:preBuild
:app:preDebugBuild
:app:checkDebugManifest
:app:preReleaseBuild
:head:appengineDownloadSdk
:head:compileJava
warning: Implicitly compiled files were not subject to annotation processing.
  Use -proc:none to disable annotation processing or -implicit to specify a policy for implicit compilation.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 warning

:head:processResources UP-TO-DATE
:head:classes
:head:appengineEndpointsGetClientLibs
API client library written to C:\Users\Juan\AndroidStudioProjects\Komi\head\build\client-libs\registration-v1-java.zip
API client library written to C:\Users\Juan\AndroidStudioProjects\Komi\head\build\client-libs\messaging-v1-java.zip
:head:appengineEndpointsExpandClientLibs

The two showed API client library are the ones based in objectify and but the third one (JDO based) is missing and seems to be being skipped.I would appreciate some help, thank you!

This is the gradle file (not different from docs):

buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
    }
    dependencies {
        classpath 'com.google.appengine:gradle-appengine-plugin:1.9.9'
    }
}

repositories {
    mavenCentral();
}

apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'appengine'

sourceCompatibility = 1.7
targetCompatibility = 1.7

dependencies {
  appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.9'
  compile 'com.google.appengine:appengine-endpoints:1.9.9'
  compile 'com.google.appengine:appengine-endpoints-deps:1.9.9'
  compile 'javax.servlet:servlet-api:2.5'
  compile 'com.googlecode.objectify:objectify:4.0b3'
  compile 'com.ganyo:gcm-server:1.0.2'
  compile 'javax.jdo:jdo-api:3.0.1'
  compile 'org.datanucleus:datanucleus-core:3.1.4'
  compile 'org.datanucleus:datanucleus-api-jdo:3.1.3'
}

appengine {
  downloadSdk = true
  appcfg {
    oauth2 = true
  }
  endpoints {
    getClientLibsOnBuild = true
    getDiscoveryDocsOnBuild = true
  }
}

Solution

  • I fixed a couple of things in order to make it work (thanks to @loosebazooka)

    1) First add the endpoints to the web.xml

    <servlet>
            <servlet-name>SystemServiceServlet</servlet-name>
            <servlet-class>com.google.api.server.spi.SystemServiceServlet</servlet-class>
            <init-param>
                <param-name>services</param-name>
                <param-value>com.something.else.Userendpoint, com.something.else.AnotherEndpoint</param-value>
            </init-param>
        </servlet>
        <servlet-mapping>
            <servlet-name>SystemServiceServlet</servlet-name>
            <url-pattern>/_ah/spi/*</url-pattern>
        </servlet-mapping>
    

    2) I had an error in my dependencies (different versions for datanucleous-core and datanucleous-jdo-api. As soon as I changed the dependencies to both 3.1.3 version enhancing started to work fine and Google endpoints became awesome again.