Square Terminal SDK for Android?

On the Terminal API Quickstart page, the first snippet of code shows how to “Create device code”.

And when you select Java (for my Android application), it gives this code:


DeviceCode deviceCode = new DeviceCode.Builder("TERMINAL_API")
  .name("Counter 1")
  .locationId("NHT...CGJ")
  .build();

CreateDeviceCodeRequest body = new CreateDeviceCodeRequest.Builder("123-456-789", deviceCode)
  .build();

devicesApi.createDeviceCodeAsync(body)
  .thenAccept(result -> {
    System.out.println("Success!");
  })
  .exceptionally(exception -> {
    System.out.println("Failed to make the request");
    System.out.println(String.format("Exception: %s", exception.getMessage()));
    return null;
  });

However, when I add that code to my Android application, I get these errors:

  • Cannot resolve symbol ‘DeviceCode’
  • Cannot resolve symbol ‘CreateDeviceCodeRequest’
  • Cannot resolve symbol ‘devicesApi’

So is there an SDK I should be using that will resolve these unknown classes?

:wave: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

Additional Documentation

Square Java SDK Quickstart
Reader SDK Quickstart
Reader SDK Quickstart

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

The code snippet you’re referring to is for the Square Java SDK, which is typically used for server-side applications. For an Android application you’ll need to modify it to call the our API through your mobile app. :slightly_smiling_face: