Return to AWS IoT Device SDK for Android README
The Android sample builds an app that can be installed and run on an Android Device. The app builds and allows you to run the following samples from aws-iot-device-sdk-java-v2:
Jump To:
The individual samples within the app require specific files to operate. The files MUST be placed in the
app/src/main/assets directory prior to building for the sample app to connect to IoT Core and complete
successfully. The names of the files must be exactly as provided. Explanations for what each file and
associated argument are doing can be found in the individual Sample README
files linked below.
endpoint.txt- IoT ATS Endpoint
certificate.pem- IoT Thing Certificateprivatekey.pem- IoT Thing Private Key
keychainAlias.txt- Alias of PrivateKey to access from KeyChain- The sample app must have permission to access KeyChain. The PrivateKey for given alias must also be granted prior to running the KeyChainPubSub sample. This can be done by selecting the
KeyChain Alias Permissionfrom theSelect a Sampledropdown menu and selecting the PrivateKey associated with the alias.
- The sample app must have permission to access KeyChain. The PrivateKey for given alias must also be granted prior to running the KeyChainPubSub sample. This can be done by selecting the
topic.txt- specifies --topic CLI argumentmessage.txt- specifies --message CLI argumentcount.txt- specifies --count CLI argument
clientId.txt- specifies --clientId CLI argument
# Change to the app directory
cd samples/Android/app
# Use gradlew from the android folder to build the sample app
../../../android/gradlew build
# Install it to a connected Device
../../../android/gradlew installDebugThe following links will provide more details on the individual samples available in the Android sample app.
This error typically occurs when non-XML files are placed in the app/src/main/res/ directory. Android enforces strict rules on what can be included in the res/ folder. If you're working with test or data files (e.g., .txt in our sample), you MUST place them in the app/src/main/assets/ directory instead.
These code examples interact with services that may incur charges to your AWS account. For more information, see AWS Pricing.
Additionally, example code might theoretically modify or delete existing AWS resources. As a matter of due diligence, do the following:
- Be aware of the resources that these examples create or delete.
- Be aware of the costs that might be charged to your account as a result.
- Back up your important data.