Search code examples
androidapkwear-osandroid-sdk-toolsandroid-install-apk

How to automatically push APK from mobile to wear?


This is my first question on Stack Overflow so please let me know if I should format it differently.

I am writing an Android Mobile (phone) app that will interact with a companion Android Wear (watch) app. Both of these apps work when I install them directly via adb. I am trying to create an APK that will install onto phone from an email attachment and push the companion app to my watch automatically. However, when I create an APK and install it via email attachment, this APK does not successfully push the companion app to my watch.

When I read the installation logs via $ adb -d logcat | grep 1329, I get the following result (below). Would anyone happen to know what I am doing wrong? I have attempted to look up the error messages online but have not found anything useful.

D/ResourcesManager( 1329): creating new AssetManager and set to /data/app/com.google.android.gm-2/base.apk
D/skia    ( 1329): --- SkImageDecoder::Factory returned null
W/AssetUtil( 1329): loadBitmapAssetFromResources: failed to decode bitmap resource for package com.google.android.gm
D/skia    ( 1329): --- SkImageDecoder::Factory returned null
W/AssetUtil( 1329): loadBitmapAssetFromResources: failed to decode bitmap resource for package com.google.android.gm
I/art     ( 1329): Background partial concurrent mark sweep GC freed 72449(3MB) AllocSpace objects, 22(5MB) LOS objects, 40% free, 18MB/31MB, paused 1.452ms total 197.557ms
D/ResourcesManager( 1329): creating new AssetManager and set to /system/priv-app/SecDownloadProvider/SecDownloadProvider.apk
W/ResourceType( 1329): No package identifier when getting value for resource number 0x00000000
W/PackageManager( 1329): Failure retrieving resources for com.android.providers.downloads: Resource ID #0x0
D/ResourcesManager( 1329): creating new AssetManager and set to /data/app/com.slightlyrobot.motion_record_phone_and_wear-2/base.apk
I/WearablePkgInstaller( 1329): Setting DataItem to install wearable apps for com.slightlyrobot.motion_record_phone_and_wear
D/ResourcesManager( 1329): creating new AssetManager and set to /data/app/com.slightlyrobot.motion_record_phone_and_wear-1/base.apk
I/WearablePkgInstaller( 1329): Companion package metadata matches, not requesting installs for com.slightlyrobot.motion_record_phone_and_wear
I/art     ( 1329): Explicit concurrent mark sweep GC freed 59365(2MB) AllocSpace objects, 4(1013KB) LOS objects, 39% free, 18MB/31MB, paused 699us total 161.260ms
D/ResourcesManager( 1329): creating new AssetManager and set to /data/app/com.google.android.gm-2/base.apk
D/skia    ( 1329): --- SkImageDecoder::Factory returned null
W/AssetUtil( 1329): loadBitmapAssetFromResources: failed to decode bitmap resource for package com.google.android.gm
D/skia    ( 1329): --- SkImageDecoder::Factory returned null
W/AssetUtil( 1329): loadBitmapAssetFromResources: failed to decode bitmap resource for package com.google.android.gm
D/ResourcesManager( 1329): creating new AssetManager and set to /system/priv-app/SecDownloadProvider/SecDownloadProvider.apk
W/ResourcesManager( 1329): Asset path '/system/framework/secsmartcard.jar' does not exist or contains no resources.
W/ResourceType( 1329): No package identifier when getting value for resource number 0x00000000
W/PackageManager( 1329): Failure retrieving resources for com.android.providers.downloads: Resource ID #0x0
W/ResourceType( 1329): No package identifier when getting value for resource number 0x00000000
W/PackageManager( 1329): Failure retrieving resources for com.android.providers.downloads: Resource ID #0x0
W/ResourceType( 1329): No package identifier when getting value for resource number 0x00000000
W/PackageManager( 1329): Failure retrieving resources for com.android.providers.downloads: Resource ID #0x0
D/ResourcesManager( 1329): creating new AssetManager and set to /data/app/com.slightlyrobot.motion_record_phone_and_wear-2/base.apk
I/WearablePkgInstaller( 1329): Setting DataItem to install wearable apps for com.slightlyrobot.motion_record_phone_and_wear

There are also many, many lines of W/StreamManager( 1329): Dropping non-bitmap icon from notification. interspaced through the output. I have removed them for clarity.

Notes

  1. I am using the command-line SDK toolset, and have signed apps in accordanace with the "Package Manually" instructions on the Android developer's webpage and "Signing your Applications".
  2. I am currently using the Android SDK command-line toolkit but am willing to use Android Studio if necessary.
  3. Hardware: I am testing this on a Samsung Galaxy S5 and an Asus ZenWatch 2.
  4. I renamed the wear apk from "wear-release-unsigned.apk" to "wear_release_unsigned.apk" when I put it in the mobile app's /res/raw/ directory. Contrary to the name, it is actually signed.
  5. Original source code is available on github.

Thank you all, very much.

Update

I have bumped the versions on the phone and wear app. Logs follow below. Like last time, these are grep'ed for 1329. I have also removed the "dropping non-bitmap" lines.

D/ResourcesManager( 1329): creating new AssetManager and set to /system/priv-app/SecDownloadProvider/SecDownloadProvider.apk
W/ResourcesManager( 1329): Asset path '/system/framework/secsmartcard.jar' does not exist or contains no resources.
I/art     ( 1329): Explicit concurrent mark sweep GC freed 45349(2MB) AllocSpace objects, 3(304KB) LOS objects, 39% free, 18MB/31MB, paused 869us total 143.177ms
D/ResourcesManager( 1329): creating new AssetManager and set to /system/framework/framework-res.apk
W/asset   ( 1329): Asset path /system/framework/com.ipsec.client.jar is neither a directory nor file (type=1).
W/ResourcesManager( 1329): Asset path '/system/framework/com.ipsec.client.jar' does not exist or contains no resources.
D/ResourcesManager( 1329): creating new AssetManager and set to /system/priv-app/SecDownloadProvider/SecDownloadProvider.apk
W/ResourcesManager( 1329): Asset path '/system/framework/secsmartcard.jar' does not exist or contains no resources.
W/ResourceType( 1329): No package identifier when getting value for resource number 0x00000000
W/PackageManager( 1329): Failure retrieving resources for com.android.providers.downloads: Resource ID #0x0

Solution

  • Well, I solved my own problem. According to the Android developer webpage, "It's important that you read and understand Signing Your Applications". They then link to a page I did not fully read.

    By adding a proper configuration to my build.gradle file instead of signing manually with jarsigner, everything installed just fine.

    https://developer.android.com/tools/publishing/app-signing.html