Search code examples
google-app-engineandroid-studiofirebasegoogle-cloud-endpoints

Error Generating Client Libraries for Cloud Endpoints Frameworks 2.0


I am building a Google App Engine app along with Firebase and I would like to use the newest features of Google cloud endpoints (version 2) such as user authentication and support for Firebase read/writes which is my main concern.

After going through the official documentation I am stuck at generating the client API libraries... Apparently as stated here it should be done manually as Android Studio does not support the function at this moment (even after updating the relevant files as stated here) it produces this error :

Error:Execution failed for task ':endpointVag:appengineEndpointsGetClientLibs'. There was an error running endpoints command get-client-lib: web.xml must have 1 (found:0) SystemServiceServlet servlet

Following the instructions from here and after running this command:

C:\android_project_path\endpoints-framework-tools-2.0.0-beta.11\bin>endpoints-framework-tools.bat get-client-lib --war=C:\android_project_path\src\main\webapp -l java -bs gradle com.somename.project.endpoints.MyEndpoint

I get the following error :

Error: com.somename.project.endpoints.MyEndpoint

Any suggestions what is going on here or how to properly generate the client libraries manually??

Thanks!

Edit, I am attaching the contents of my web.xml.

<?xml version="1.0" encoding="utf-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee">
<servlet>
    <servlet-name>EndpointsServlet</servlet-name>
    <servlet-class>com.google.api.server.spi.EndpointsServlet</servlet-class>
    <init-param>
        <param-name>services</param-name>
        <param-value>com.somename.project.endpoints.MyEndpoint</param-value>
    </init-param>
    <init-param>
        <param-name>restricted</param-name>
        <param-value>false</param-value>
    </init-param>
</servlet>

<servlet-mapping>
    <servlet-name>EndpointsServlet</servlet-name>
    <url-pattern>/_ah/api/*</url-pattern>
</servlet-mapping>

<welcome-file-list>
    <welcome-file>index.html</welcome-file>
</welcome-file-list>

<filter>
    <filter-name>endpoints-api-configuration</filter-name>
    <filter-class>com.google.api.control.ServiceManagementConfigFilter</filter-class>
</filter>
<filter>
    <filter-name>endpoints-api-controller</filter-name>
    <filter-class>com.google.api.control.extensions.appengine.GoogleAppEngineControlFilter</filter-class>
    <init-param>
        <param-name>endpoints.projectId</param-name>
        <param-value>myproject</param-value>
    </init-param>
    <init-param>
        <param-name>endpoints.serviceName</param-name>
        <param-value>myproject.appspot.com</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>endpoints-api-configuration</filter-name>
    <servlet-name>EndpointsServlet</servlet-name>
</filter-mapping>
<filter-mapping>
    <filter-name>endpoints-api-controller</filter-name>
    <servlet-name>EndpointsServlet</servlet-name>
</filter-mapping>


Solution

  • It looks like this is your issue:

    --war=C:\android_project_path\src\main\webapp
    

    The --war parameter must point to the root of the exploded WAR directory of your compiled app. You're pointing it to the 'webapp' folder of your app's source. You'll notice the example given in the docs your referenced is target/echo-1.0-SNAPSHOT.

    To be sure I've tested this with a sample app on a Linux and Windows system (using the latest endpoints-frameworks-tools version 2.0.3) and the client libs were generated without problems.