Since I'm really not a fan of Eclipse I'm developing my Android app by following the rules listed here: http://developer.android.com/guide/developing/other-ide.html
When I'm deploying with the 'adb install' command I have to manually uninstall the APK from the emulator every time or else the install won't work. Is there any way to bypass this? It's fairly annoying having to add this step in every time.
Yes, use the adb install -r switch.
Running adb with no options will give help.
Related
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.
I'm working on an app that uses device admin. If I run the app on a device using eclipse, then make a minor change to the code, then run the app again, the app runs as you'd expect with the new change.
However, if the second time I run the app I use adb install I get:
Failure [INSTALL_FAILED_ALREADY_EXISTS]
If I try to uninstall then reinstall, the uninstall fails because the app is device admin. This has led me to wonder which adb commands eclipse executes when you select run. I've looked for some sort of "update" command but I couldn't find one. Anyone know?
You can use "adb install -r yourapp.apk" to install your system apk again.
If you want to run through command line, use
"adb shell am start -n acticityname_withpackage"
I have an app that closes itself after it's finished. If I install it through eclipse, it works normally, but if I install it through adb -e or -d install c:\....\myApp.apk, it works but it doesn't close itself after finished.
I need to install it via adb and I need it to close when it's done, like it does when installing from eclipse. Why does it have different behavior for the same apk and how can i fix this?
thanks
Like Siddharth Lele posted, the difference was on the signing key, exporting the apk with eclipse's default key fixed the problem.
I'm tired of uninstalling and than reinstalling in development.
Is there a way to do adb -force install some.apk ? I mean this would save a lot of time. Each time going to system ->apps->uninstall every time a signature is different.
Obviously debug is a dev setting so I don't see why one constantly needs to uninstall the app manually, what a waste of time? Anything that can make development easier is going to result in better code, and better apps so whats up with this?
I have hot deployed to server side Java EE servers in less time. This is less an issue on command line, since one could do an uninstall or replace the adb script with an uninstall followed by an install.
However in eclipse its still a pain. It has been pointed out that this is largely about signature changes. Yes, it is. But why should signatures change in development, and debug mode, and cause the reinstallation issue?
adb has [-r] parameter to reinstall.
adb install -r some.apk
A web search you could have done reveals that the answer to your adb question is:
adb uninstall some.package.name
Note that it's not the file.apk name you use with adb install, but rather the actual package name it ends up installed as.
The normal build process uses the android debug keystore that can be found in your android folder in your home directory (path depends on your OS).
With this debug keystore your app will be signed. This debug signature can be installed on every android device in the world as long as there isn't your app with another signature already installed.
When you say you only do code checkouts, rebuild and your signature is different, than probably your build process is broken. Your debug keystore is valid for at least a year and as long as you are on the same PC while building the generated APK should never have a different signature.
For further checking you should bring some light in your development process. What do you use? Eclipse?
If you work on different developing machines, pick one keystore from one machine and put it into your version control and use this to sign your apk with the debug signature.
adb install -r -d path/to/file.apk
-r to replace
-d to force downgrade
You can install an app forcefully by passing -r parameter.
-r parameter lets adb to reinstall the app.
adb install -r app-release.apk
The debug keystore can be set in Eclipse in Preferences/Android/Build/Custom debug keystore, which is very helpful when working in a team. Every member should set up the same keystore there, and then it is no problem any longer to share devices.
for uninstall
adb uninstall app_package_name
for install
adb install app_package_name
into the command prompt in windows
and terminal in linex/Macos
When I want to test an android application, I create a new AVD, start it in the emulator, wait for the emulator to finish booting, and then use ADB to install the application, and when I'm done delete the AVD. Are there any tools that automate all of those steps? I tried writing my own but I couldn't find a way to tell if the emulator was completely booted, as the Android SDK website says not to use "adb wait-for-device install file.apk".
You're right not to use wait-for-device. It does not wait for the package manager to be available, which is what you need. I'm not sure how eclipse does it but you can poll the emulator until the package manager is available using the command adb shell pm path android. The command should return 'package: something'. Check out this python script that uses the technique: www.netmite.com/android/mydroid/1.6/.../adb_interface.py. It's pretty big but if you search for the command above you'll find the relevant piece of the script.
Why do you want to delete the AVD every time?
If you are deleting it every time because the install command throws an error due to the app already existing on the AVD, you can do this: adb install -r file.apk. The -r part is used for reinstalling the app. Here is the full usage instructions for adb.
Are you deleting it to remove the application you are testing and revert to a 'clean' emulator? If so it's not necessary to delete the AVD every time. You can specify the -wipe-data option when starting the emulator. This effectively resets the AVD to how it was when you created it. Here is the emulator documentation.
Hopefully that helps simplify your script.