Unable to install apk in android emulator - android

I am trying to install an apk (downloaded from one site) in ICS emulator through adb shell but its giving following error:
Failure [INSTALL_FAILED_UID_CHANGED]
What could be the issue?

Simply rm -r the data directory in question. If you were installing and got this error, you'd simply run "rm -r /data/data/com.app.class" from an ADB shell. If you want to try preserving the data, you could find the proper UID and then "chown -R UID:UID /data/data/com.app.class".
In Android, the part of the source code that handles installing apps is PackageManagerService. Since the Android source is public, it's easy to see where Android will throw a INSTALL_FAILED_UID_CHANGED error. If the following is true: the package you are installing already has a data directory AND the permissions on that data directory are different than the UID assigned to this package, you'll get that error.

Uninstall the previous version of the app from the emulator first, then try again. You can do this by visiting System Settings > Applications > Manage Applications and selecting the app.
If the app still fails to install, then start the emulator with the Wipe user data option selected.

Open command prompt and write below code in it:
adb devices
This will list down the number of devices attached or are active.Copy your apk in your System folder
adb -s DEVICE_NAME install YOUR_APK_NAME
through this you will be able to install your particular apk on the device by giving device name in above line.

Related

uninstall app fully still appears the error INSTALL_FAILED_VERSION_DOWNGRADE when I install my app

background:
1. I have installed the APK with the 1.1.30 version built by flutter.
2. I want to install it back to 1.1.29
3. I uninstall the 1.1.30 app.
4. I install the 1.1.29 package, and it will throw the error package appears to be invalid.
5. I try to use ADB to install it, but the error will change to INSTALL_FAILED_VERSION_DOWNGRADE: Package Verification Result
6. no idea why the app built by flutter will cause this issue, even if I uninstall the app fully.
7. the solution is using ADB install -r -d [path_to_debug_apk] to replace and downgrade the app.
can someone explain why this happened? is the app can not uninstall completely? thanks.
also refer to this link: Error: ADB exited with exit code 1 Failure [INSTALL_FAILED_VERSION_DOWNGRADE]
it seems the same to me who still can not install it even though the app was removed.
some information added:
I used adb shell cmd package list packages, can not find my app but the command with adb shell dumpsys package[pageckage name] can find my app.
so weird

ADB installs apk but doesn't show under packages

I am trying to uninstall an old version of my app, and reinstall the new version via ADB on a Lollipop Android device. These are my current steps:
adb uninstall com.company.mypackagename
adb install app-release.apk
adb shell pm list packages
The original uninstall of my old app was successful and the app disappeared from the Android 5.5 device.
The new attempt to install the upgraded app returns:
adb install app-release.apk
Performing Push Install
app-release.apk: 1 file pushed, 0 skipped. 10.7 MB/s (822124 bytes in 0.073s)
pkg: /data/local/tmp/app-release.apk
Success
but when I run a list of the packages, my new APK package is not there.
adb shell pm list packages
When I try to run it anyway:
adb shell am start -n "com.company.mypackagename/com.company.mypackagename.MainActivity"
I get:
Error: Activity class {com.company.mypackagename/com.company.mypackagename.MainActivity} does not exist.
So obviously it is not installing correctly, as it is not showing in packages and unable to run - even though it shows Success. What is the best way to troubleshoot this? Any help appreciated!
I finally found the issue!!!
I'm posting here because I spent way too much time trying to figure this out, since it wasn't giving me any error messages.
I was able to get a copy of the original APK from the deployment team and analyze their AndroidManifest.xml, and saw that the original APK package name was all lowercase: "com.company.mypackagename" but the one I was building was actually using Camel-Case "com.company.myPackageName". When I tried to install it, ADB should have given an error similar to: "Application ID Does not Match", but instead it just repeatedly gave me a response of: "Success".
Hopefully this saves someone else some time!

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.

App does not install on android device by an unknown failure

I try installing my app for the first time on a Nexus 5.
The android studio then tells me I need to uninstall my app inorder to install it (The app never exsited on the phone) and then asks me to unistall the app, I agree and he tries to unistall but an error occurs:
Waiting for device.
Target device: lge-nexus_5-08a9df88021f8ec8
Uploading file
local path: D:\USER\Desktop\Yoav\AndroidProject\Example\app\build\outputs\apk\app-debug.apk
remote path: /data/local/tmp/com.example.user.example
Installing com.example.user.example
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.example.user.example"
pkg: /data/local/tmp/com.example.user.example
Failure [INSTALL_FAILED_DEXOPT]
At this part the studio asks me to uninstall after pressing ok:
DEVICE SHELL COMMAND: pm uninstall com.example.user.example
Unknown failure
I think it's because the app does not exsit on the phone, but if the app does not exsit why does it even want me to delete it?
It might be because of the package name. Check weather is there any app with the same package name that you created before. com.example is not a good practice to use for you practice projects even.
I may be not right but from the information provided this is what I can say.
It happenes because the .apk you built and are trying to install is missing the classes.dex file. This can happen for various reasons but most of the time (for me) the build process gets stuck somehow.
Open Task Manager and kill all following processes:
cmd.exe
conhost.exe
find_java.exe
Then clean and build your project.
Also make sure you use latest Build tools (now 21.1.1).
I had the same problem. I finally had to reboot the device to solve it.

Android APK INSTALL_FAILED_UID_CHANGED Now Premission Denied

I have been working with Monkey Talk and Xamarin Android. With my APK generated by Xamarin the Monkey Talk instrumentation would not work. Yesterday I got it to work by pushing the assemblies to the /data/data/com.app/files/.override folder. I hacked around until I got it to work and changed the chmod on some folders, added a folder to /data/data/com.app/ and got it to work.
Today I uninstalled the working build so that I could automated what I had done. After running "adb uninstall com.app" then running the install for the base APK, I keep getting "INSTALL_FAILED_UID_CHANGED".
I have seen similar threads suggesting params you can add to the uninstall.
The following did NOT work:
adb shell pm clear com.app
adb -d install -r com.apk
adb shell; rm -r /data/data/com.app (permission denied)
(push to sdcard then) adb shell pm install -l /sdcard/tmp/smv.apk
redownloading the app from the app store
If this was before I uninstalled I could have used "run-as com.app", but now since the app is no longer I can't get permissions to remove the lingering data folder. "run-as: Package 'com.app' is unknown"
I want to avoid rooting the device. But how in the world can I get rid of the old files? Can I restore the ability to use run-as? I also don't want to reinstall Android ...
Try to reboot your device before reinstalling the app. That worked for me.

Categories

Resources