Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Nesta página, mostramos como gerar uma biblioteca de cliente pelo back-end da API. Qualquer app para Java ou Android pode usar essa biblioteca para chamar a API.
As instruções a seguir mostram como usar os plug-ins Apache Maven e Gradle do Cloud Endpoints Frameworks para gerar um pacote de cliente do Gradle com base no projeto de amostra do Maven em Primeiros passos com o Endpoints.
Para gerar uma biblioteca de cliente:
Crie sua API.
Execute a ferramenta de linha de comando do Endpoints Frameworks de forma semelhante à seguinte:
Maven
mvnendpoints-framework:clientLibs
Gradle
gradleendpointsClientLibs
Aguarde a ferramenta gerar a biblioteca. Quando terminar, uma mensagem como esta será exibida:
Maven
API client library written to target/client-libs/echo-v1-java.zip
Gradle
API client library written to build/endpointsClientLibs/echo-v1-java.zip
Descompacte o arquivo usando o utilitário de descompactação ou use outro utilitário de desarquivamento compatível com ZIP:
unzip./echo-v1-java.zip
Altere o diretório:
cdecho
Crie a biblioteca de cliente:
Maven
mvncleanpackage
A saída está no diretório target/.
O nome do arquivo exato depende da versão do cliente Java. É algo semelhante a echo-v1-1.23.0-SNAPSHOT.jar.
Gradle
gradlebuild
A saída está no diretório build/libs. O nome de arquivo exato depende da versão do cliente Java. É algo semelhante a echo-v1-1.23.0-SNAPSHOT.jar.
Adicione o JAR da biblioteca cliente ao seu aplicativo Java ou Android.
Repita essas etapas toda vez que você modificar o código da API.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-09-04 UTC."],[[["\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)."]]