A collection of Java samples for the Play Developer API.
-
Download the Google Play Developer API client library: https://developers.google.com/android-publisher/libraries
-
Unzip the client library. The unzipped folder contains the google-api-services-androidpublisher-v2.jar client library and a lib/ folder with all required dependencies.
-
Import the Java sample code into your favorite IDE and reference all libraries in the /lib folder as well as the google-api-services-androidpublisher-v2.jar from the sample project.
To use the Google Play Developer API you need to create or reuse an existing API project in the Google Api console, https://console.developers.google.com/. You can either use the API with a client ID for Native Application (Installed Application) or create a Service Account.
-
Specify the name of your application. If the application name is null or blank, the application will log a warning. Suggested format is
MyCompany-Application/1.0
. -
Specify the package name of the app as per developer console.
-
If you want to run any of the upload apk samples, please copy your apk to the
/resources
folder and specify the apk file path, i.e./resources/your_apk.apk
-
Edit the
/resources/client_secrets.json
file and add the client ID, client secret and redirect uris. -
Execute any sample class using its
main()
method to begin the auth flow:
A browser window will open and ask you to login. Make sure the account has appropriate permissions in the Google Play Developer console.
- Accept the permissions dialog. The browser should display
The authentication flow has completed.
Close the window and go back into your IDE and check the console output.
-
The script will output a list of apks.
-
The tokens will be stored in
.store/android_publisher_api
in your home folder. Remove this file to restart the auth flow.
-
Edit
ApplicationConfig.java
and add the service account email address. -
Copy the service account key file, generated in the Google APIs Console into the same directory and rename it to
key.p12
. -
Execute any sample class using its
main()
method in your IDE -
The script will output a list of apks.
You're all set and ready to run the Play Developer API samples. Thank you for being such a great developer on Google Play, your feedback is very important to ensure that Google continues to improve the developer experience on Play! Enjoy :-).