How to create Android Things' bundle and push

2019-01-28 12:26发布

问题:

Anyone succeeded creating Android Things Bundle and pushing it over OTA?

On the Android Things' Console, there's a page to Create a Bundle for the OTA.

I'm trying to figure out how to do that. I've adding just a single APK file main.apk to a ZIP file. Then I've tried to push it to a RPi which is sitting nearby. But the main.apk would not be launched on the device.

Things I've tried/done:

  • Download Empty bundle with Things Build ID=NIH40K
  • Creating a Bundle and pushing it to devices through OTA UPDATES
  • Creating a new FACTORY IMAGE with that newly created bundle
  • Still my app would not be started
  • I've checked, my app's MainActivity has action=MAIN and category=IOT_CATEGORY
  • Tried running app from my laptop via adb connect Andorid.local and it works as designed

But I couldn't make an OTA update. Anyone succeeded doing so?

Here's my project on Github: https://github.com/ViliusKraujutis/Android-Things-Demo

Thanks

回答1:

Here are all the steps necessary to make OTA update possible after creating a new product in your android things console :

1 - Create your first build configuration, either from the empty bundle in the console or from a personnal bundle you added.

2 - Download build of this build configuration. You will get an Android Things image. Flash it to your RPi as you did when you flashed the Android Things regular image. https://developer.android.com/things/hardware/raspberrypi.html#flashing_the_image

From now on, your RPi will check if a different version of your product has been pushed from the console. The check happens every 5 or 6 hours so you might have to be patient. Also your RPi needs to have internet access.

3 - Upload another bundle to your console, create a build configuration for it and then push it to your devices via the OTA updates panel of your console.

4 - You will need to manually reboot the RPi to apply the update.

This article from Dave McKelvie is a good example in my opinion : http://android.geek.nz/hello-android-things-developer-console/



回答2:

I had a problem with getting the main apk to run. Turns out if your custom animation is misconfigured the main apk will fail to load and it will never be launched. I solved the problem by installing a stock build with empty bundle. Using adb to connect and retrieve the existing animation. I then used this animation along with my main apk to create a bundle. I loaded this image on my device and my main app loaded just fine.