2

I am developing an app for a wear device and I wanted to include the possibility to update the app by pressing a button.

This action will download an updated version of the app from a private server and run the .apk file to install, for that I have been following the code on this answer.

Everything works as expected on a real android phone but when I try to run the app in a wear device, it works to the point of downloading the updated .apk file, but the installation fails with the following message:

enter image description here

I was wondering if anybody could provide a better way to add update feature to an Android Wear app.

codeKiller
  • 5,493
  • 17
  • 60
  • 115

2 Answers2

1

It looks like PackageInstaller is denying installation of arbitrary APKs (see code here), so you're probably out of luck. Installing arbitrary APKs is not usually an action which is possible as it requires being a system/privileged app (it should require android.permission.INSTALL_PACKAGES, and the only other app on the device which supports installing packages is most likely Play Store.

If you want a way to update things automatically you're stuck w/ putting it on Google Play.

z153
  • 156
  • 5
  • ok, thanks for your answer, what if the device is rooted and the app could be installed as system app?...not saying that can be possible in my case, but just curious... – codeKiller Feb 19 '18 at 07:24
  • In theory it could work (most anything can work w/ root), though I'm not sure of the specifics. Why would you want to have your own update mechanism anyway? Normally you could just fire an intent to the play store URI for the app – z153 Feb 21 '18 at 21:01
  • lets just say that this is kind of an special project, where no google services can be used – codeKiller Feb 22 '18 at 07:38
1

So this answer isn't the best way of getting around something. But, if you want to download and install an APK File that is not in the Android Wear Google Play Store. You can use ADB and sideload the APK From your computer.

Here is how to set it up

  1. Have you're built APK File

  2. Depending on your System, install ADB

    2a.Windows - Go to here https://forum.xda-developers.com/t/official-tool-windows-adb-fastboot-and-drivers-15-seconds-adb-installer-v1-4-3.2588979/ and install the latest patch

    2b. MacOs - brew install adb

    2c. Linux - sudo apt-get install adb fastboot -y

  3. On your Android Wear Device, enable ADB Debugging

  4. Connect device to computer (can be usb connection) or via Bluetooth (very slow, but not all Android Wear Devices have a USB Connection to them)

  5. Now type adb devices to start the adb server and click allow on your android device

  6. Time to install apk file - type: adb install path/to/file

bwan1011
  • 55
  • 8