Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Auf dieser Seite wird beschrieben, wie Sie eine Clientbibliothek aus Ihrer Back-End-API generieren. Diese Bibliothek kann von jeder Java- oder Android-App zum Aufrufen der API verwendet werden.
Die folgenden Anweisungen zeigen, wie die Cloud Endpoints Frameworks Apache Maven und Gradle-Plugins verwendet werden, um ein Gradle Client-Bundle aus dem Beispiels-Maven-Projekt Erste Schritte mit Endpoints zu generieren.
Clientbibliothek generieren:
Erstellen Sie die API.
Das Endpoints Frameworks-Befehlszeilentool sollte in etwa so ausgeführt werden:
Maven
mvnendpoints-framework:clientLibs
Gradle
gradleendpointsClientLibs
Warten Sie, bis die Bibliothek generiert wurde. Zur Bestätigung wird im Anschluss in etwa folgende Meldung eingeblendet:
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
Entpacken Sie die Datei mit dem ZIP-Programm oder verwenden Sie ein anderes ZIP-kompatibles Reaktivierungsprogramm:
unzip./echo-v1-java.zip
Wechseln Sie das Verzeichnis:
cdecho
Erstellen Sie die Clientbibliothek:
Maven
mvncleanpackage
Die Ausgabe befindet sich im Verzeichnis target/.
Der genaue Dateiname hängt von der Version des Java-Clients ab. Es ähnelt echo-v1-1.23.0-SNAPSHOT.jar.
Gradle
gradlebuild
Die Ausgabe befindet sich im Verzeichnis build/libs. Der genaue Dateiname hängt von der Version des Java-Clients ab. Es ähnelt echo-v1-1.23.0-SNAPSHOT.jar.
Fügen Sie der Java- oder Android-App die JAR-Datei der Clientbibliothek hinzu.
Wiederholen Sie diese Schritte bei jeder Änderung des API-Codes.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 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)."]]