[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-04。"],[[["\u003cp\u003eThis guide details the process of generating a client library from a backend API for use in Java or Android applications.\u003c/p\u003e\n"],["\u003cp\u003eThe client library is generated using the Cloud Endpoints Frameworks' Apache Maven or Gradle plugins, through command-line instructions.\u003c/p\u003e\n"],["\u003cp\u003eAfter building the API, run either \u003ccode\u003emvn endpoints-framework:clientLibs\u003c/code\u003e or \u003ccode\u003egradle endpointsClientLibs\u003c/code\u003e to generate a zip containing the client library.\u003c/p\u003e\n"],["\u003cp\u003eThe generated library ZIP file needs to be unzipped, and then built using either \u003ccode\u003emvn clean package\u003c/code\u003e or \u003ccode\u003egradle build\u003c/code\u003e, producing a JAR file.\u003c/p\u003e\n"],["\u003cp\u003eThe resulting JAR file, found in the target or build/libs directory, should be added to your Java or Android application for it to communicate with the API, and the process must be repeated every time the API is modified.\u003c/p\u003e\n"]]],[],null,["# Generating a client library\n\nThis page describes how to generate a client library from your backend API.\nAny Java or Android app can use this library to call the API.\n\nTo create iOS clients for your API, we recommend that you use\n[Google APIs Objective-C Client Library for REST APIs](https://github.com/google/google-api-objectivec-client-for-rest/wiki).\n\nBefore you begin\n----------------\n\n- [Set up your development environment](/endpoints/docs/frameworks/java/set-up-environment).\n- Make sure you have properly [annotated](/endpoints/docs/frameworks/java/annotate-code) your API.\n\nGenerating the client library\n-----------------------------\n\nThe following instructions demonstrate how to use the Cloud Endpoints Frameworks\n[Apache Maven](/endpoints/docs/frameworks/java/maven-endpoints-frameworks-plugin)\nand [Gradle](/endpoints/docs/frameworks/java/gradle-endpoints-frameworks-plugin)\nplugins to generate a Gradle client bundle from the sample Maven project\n[Getting started with Endpoints](/endpoints/docs/frameworks/java/quickstart-frameworks-java).\n\nTo generate a client library:\n\n1. Build your API\n\n2. Run the Endpoints Frameworks command-line tool similarly to the\n following:\n\n ### Maven\n\n ```bash\n mvn endpoints-framework:clientLibs\n ```\n\n ### Gradle\n\n ```bash\n gradle endpointsClientLibs\n ```\n\n Wait for the tool to generate the library; on success the tool displays a\n message similar to this one: \n\n ### Maven\n\n ```\n API client library written to target/client-libs/echo-v1-java.zip\n ```\n\n ### Gradle\n\n ```\n API client library written to build/endpointsClientLibs/echo-v1-java.zip\n ```\n3. Unzip the file by using the unzip utility, or use another ZIP-compatible\n unarchiving utility:\n\n unzip ./echo-v1-java.zip\n\n4. Change directory:\n\n cd echo\n\n5. Build the client library:\n\n ### Maven\n\n ```bash\n mvn clean package\n ```\n\n The output is in the `target/` directory.\n The exact filename depends on the version of the Java client. It is\n something similar to `echo-v1-1.23.0-SNAPSHOT.jar`.\n\n ### Gradle\n\n ```bash\n gradle build\n ```\n\n The output is in the `build/libs` directory. The\n exact filename depends on the version of the Java client. It is\n something similar to `echo-v1-1.23.0-SNAPSHOT.jar`.\n6. Add the client library JAR to your Java or Android app.\n\n7. Repeat these steps every time you modify your API code.\n\nWhat's next\n-----------\n\n- [Call the backend API from an Android app](/endpoints/docs/frameworks/java/calling-from-android).\n- [Learn more about Cloud Endpoints Frameworks for App Engine](/endpoints/docs/frameworks/java)."]]