Install/Uninstall action not allowed on Wear - android

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:
I was wondering if anybody could provide a better way to add update feature to an Android Wear app.

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.

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
Have you're built APK File
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
On your Android Wear Device, enable ADB Debugging
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)
Now type adb devices to start the adb server and click allow on your android device
Time to install apk file - type: adb install path/to/file

Related

Which is the best way to install apk on Android watch while developing?

I am developing an Android Wear application. As per my understanding I must use Android Wear (mobile app) and install through it to watch. For this we need to build the apk each time and save it in mobile, and install it through the mobile app, so is there a better way to install the apk in the watch or is it the standard process?
You can install Wear apk in the exact same way as normal Android application.
First, attach Wear device to your computer and allow USB debugging. Alternatively, download and start Wear emulator through Android Studio.
Next, run your app through Android Studio - you can use run or debug modes.
That's it! :)
For distribution, the process is slightly different, depending on whether you want to support Wear 1.0 or only Wear 2.0, and whether companion app is needed on the phone. For Wear 2.0, you don't need mobile app anymore, it can be distributed directly, but of course depending on functionality you might want mobile app as well.
Provided you have root privilege on your Android watch:
1.Use adb shell to connect the watch and switch to su
2.Assume your watch app is called watchapp with com.watchapp so file
chmod +777 /data
chmod 777 /data/data
chmod 777 -R /data/data/com.watchapp
#There might also be other files with suffix
chmod 777 -R /data/app-lib/com.watchapp-1
3.
#adb push your new compiled so file to overwrite that file in your watch
adb push YOURNEWSOFILEPATHONEDISK /data/app-lib/com.test-1

Manually installing an updated APK fails with "signatures do not match the previously installed version"

I've built a silly app to share among a few friends. No need to put it up on the app-store.
I built the first apk (signed), uploaded it to a web-server and all worked well.
A small issue arose, I fixed it, re-built, signed with the same keystore and uploaded it again. It now seems that I am unable to install from the new apk. The debugger tells me:
signatures do not match the previously installed version
So I uninstalled the old version by opening the app drawer and dragging it onto the "uninstall" button. When opening "Settings -> Apps", I don't see it anywhere anymore. I don't see any traces of the app on my device.
Yet I still get the above error message.
Is it possible some information still lingers on the device somewhere? Is there any way I can verify that?
Yes It is possible if somehow your old application is not removed 100% or its data is not removed.
Try:
adb uninstall "com.yourapp.yourapp"
If you don't know exactly what to put as replacement for "com.yourapp.yourapp", then you just open Android studio, Run your app while it is connected to a device and then look at Debug window.
It says:
Waiting for device.
Target device: samsung-sm_t531-xxxxxxxxx
Uploading file
local path: C:\Users\myapp\app\build\outputs\apk\myapp.apk
remote path: /data/local/tmp/com.myapp.myapp
Installing com.myapp.myapp
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.myapp.myapp"
pkg: /data/local/tmp/com.myapp.myapp
Success
com.myapp.myapp in this case is the name of the package you must use to uninstall.
I had the same issue and the adb uninstall solution did not work for me.
What worked was
On your device go to to Settings->Apps
Select your app, and in the menu select "Uninstall for all users"
Even if I had previously uninstalled the app it was still in the list there.
To me, if the app is meant to be distributed, the adb solution is a no-go: you can't ask one's friend to have the android sdk installed on their machine !
The way to go here is to edit the AndroidManifest.xml and to increment the android:versionCodeattribute in the <manifest>tag (which is the root element).
This would update your installed application
If you are seeing this while conducting connected tests, make sure to include .test when uninstalling via adb because uninstalling via app -> settings does not get rid of the test package
adb uninstall your.broken.package.test
if you just uninstall via
adb uninstall your.broken.package
your test package will still be there. This was only something i noticed while using the gradle command line, haven't come across this problem within android studio
Uninstall the old app from your phone or emulator and try to run again.
I got that error while trying to install release while signing it's certificate.
fixed with the :app Gradle task uninstallRelease and then installRelease again
If you are going in install the same app with a different signature, you may want to uninstall but keep the app's data.
adb -d shell pm uninstall -k <packageName>
adb -d install -r -t -d app.apk
For Unity users who come to this question, the best answer is indeed the one above by #Ehsan
adb uninstall "com.yourapp.yourapp"
I had already installed a previous version on my Android device then selected Development Build in Unity > Build Settings which caused the APK to use a different signature. If you install through the Android GUI it doesn't actually remove everything so you have to use ADB.
I had face same problem With POCO Mobile and Moto G30 Mobile while developing application in flutter
My Solution is:
I have open android project which automatically create in your project, in android studio and run project in connected device. It will automatically ask to uninstall old app with same package name and different signature. After click ok button it will install app.

tizen emulator not connecting to device

Hi I am trying to connect the Tizen Emulator version : 2.3.0 Rev2 to an android device.
I downloaded the files for apk files from here. I have done the port forwarding like shown below before starting the emulator :
adb -d forward tcp:8230 tcp:8230
But even after starting the Emaulator still the HostManagerForEmul shows status as disconnected.
I was following the complete instructions from the youtube video found here.
A couple things to try...
If Gear Manager is installed on the Android handset, uninstall it. Gear Manager is not compatible with HostManagerForEmul.
Restart sap-server from the emulator.
I have same problem, after struggling I have finally connected
Here is solution , Go to package manager install both highlighted from extension SDK as shown in picture
after installing connect android phone install apk provided in tutorial and run
adb -d forward tcp:8230 tcp:8230
Now delete emulator and make again, after reboot it will install extension tools and on first boot it will show like this
After that it will reboot again automatically , and on Android side it will show Connected. Done :)

Android .apk installation - Application not installed

I've installed the appropriate .apk file, however when trying to install it the app it gives me the error 'Application not installed'. I've tried to put a simple Hello World .apk file on there and I receive the same message.
Here's what I have tried:
1. Adding the following to Application Manifest
android:debuggable="true"
2. I have installed multiple File Managers including Astro, Android File Manager and ES File Explorer
3. I have enabled all of the correct settings on the Sony Xperia U (running Android 2.3.7)
4. Tried installation whilst the device is plugged in, and whilst it isn't
I'm using a Unsigned Android Application. Everything runs accordingly on the Eclipse emulator
Logcat is reporting the following:
This is displayed even when my device is connected via USB.
Locate your myapp.apk file on your hard drive:
Install it via command line:
C:\android\android-sdk\platform-tools\adb.exe install myapp.apk
List of connected devices:
adb devices
Connecting a device (if its number is 5554):
adb connect 127.0.0.1:5554
Restarting ADB:
adb kill-server
adb start-server
Your APK is having an expired or mis-configured certificate.
You need to resign the apk using the following tools.
https://play.google.com/store/apps/details?id=kellinwood.zipsigner2&hl=en
or
https://code.google.com/p/apk-signer/
Sign the APK with output filename as HelloWorld_signed.apk
Then go to my files you Will see your signed apk.
Install HelloWorld_signed.apk.
The app Will install successfully..
I believe there is a constraint of permission to prevent you to do so, I have worked around and find a simple solution for my Sony Xperia 1, OS version 5.1.1
Go through these steps:
Settings
Apps
Download Tab
Scroll down to find your app there
Press the menu and select Uninstall for all users

How to test what will happen when you publish an update to your app to the Market

I'm about to publish a new version of an app to the Market. In order to avoid any potential problems once its been pushed to the Market and people get notified of an update, I'd like to simulate that process on my phone using the .apk for the new version of the app I'll be publishing.
For instance, it has an update to the SQLite DB it's using.
The closest I can find is using the Android Debug Bridge (adb) using the command:
adb install C:\myApplication.apk
with my phone attached to my PC via the usb cable.
(the parameter represents wherever your apk file is on your PC).
When I do this, if the app is already installed on my phone, I get an error message:
Failure INSTALL FAILED ALREADY EXISTS.
If I delete the existing app from my phone, the adb install command works fine.
So, it looks like this can only be used to install an app that doesn't currently exist on your phone.
Is there any way to simulate the update process?
It'd be nice if there was an adb update command, but I don't see that.
Try using option -r to adb install:
adb install [-l] [-r] [-s] -
push this package file to the device
and install it
('-l' means forward-lock the app)
('-r' means reinstall the app, keeping its
data)
('-s' means install on SD card instead of
internal storage)
The closest I think you can get is to put the APK somewhere, and download it on a phone. That is about the closest you can get to the real market situations, with the only difference being that you need to add the "unknown sources" option.
(on a sidenote: you can get an error installing an apk with the same package-name, but a different signing.)
I think your error is because you have the market signed version installed and your trying to install a debug signed version. If you sign it with your market key it should install fine.

Categories

Resources