Setting up the Android Package Kit (APK)
You can use the SDA SDK in Android applications to implement an SDA technician application that logs into Pelion Device Management, requests an access token and then connects to the IoT device to instruct it to perform the requested operation.
To include the secure device access SDK as a library in your project and build the APK:
Clone the SDA SDK GitHub repository to your computer.
To connect to Device Management, you must provide your application with the Device Management base URL, your device's endpoint name or device ID and your account ID by editing the
<resources> <string name="env_url">https://api.us-east-1.mbedcloud.com</string> <string name="account_id">Your account ID goes here</string> <string name="device_ep">Paste your device endpoint name from the developer certificate</string> </resources>
**Notes about endpoint name:**
env\_urlis the Device Management base URL (this URL is different only if you have Device Management on-premises).
account_idis your account ID, which you can see in Device Management Portal by selecting Team configuration > Team profile from the side menu.
device_epis the device endpoint name, which you can see in the
mbed_cloud_dev_credentials.cfile you downloaded earlier.
For the convenience of the demo and for development purposes, you can provide a default endpoint name in the `arm-sda-android/app/src/main/res/values/properties.xml` file, as described above. You can also use tools such as [Android Debug Bridge (adb)](https://developer.android.com/studio/command-line/adb) to supply long names to the application. In the field, a technician would enter the endpoint name in the SDA technician application or use the device ID if the device has bootstrapped. Bootstrapping the device enables you to associate custom properties to the device, such as assigning the device to a region to which a certain policy applies.
In the `mbed_cloud_dev_credentials.c` file, note the device endpoint name in the following line: `const char MBED_CLOUD_DEV_BOOTSTRAP_ENDPOINT_NAME = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";`.
When you run the demo application on your device, only the first 15 characters are shown because of display limitations. The actual device endpoint name that you must always use is the **full value** above.
JAVA_HOMEpoints to the Java JDK:
set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_131
export JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"
ANDROID_HOMEpoints to the Android SDK (for information about Android SDK download, installation and supported versions, see Working environment requirements):
export ANDROID_HOME= ~/Library/Android/sdk/
Note: During the installation process, the Android installer tells you where the SDK is.
Run the following command:
gradlew clean build -x test -x check
The Android application file is
Install the APK on the Android device
There are multiple ways to install applications on an Android device. We suggest:
- Enable Unknown sources in the settings of your Android device. This is typically under Lock screen and security.
- Connect the Android device to the PC using a USB cable. On a Mac, the Android device does not show up automatically as a USB mass storage device; therefore, you must install an application to copy files from your Mac to the Android device.
- Copy the APK file (
arm-sda-android/app/build/outputs/apk/debug/app-debug.apk) to your Android device.
- If you have a previous version of the APK on your Android device, uninstall it.
- On your Android device, use a file manager to find the file you just copied, and click to install it.