Xamarin Android Deployment failed because of an internal error - android

When I try to deploy a Xamarin Forms Android app to my Samsung S4 I get the following error message:
Deployment failed because of an internal error: Package /data/local/tmp/de.tradino_shop.pinkweather-Signed.apk already exists on device.
I looked for the file and wanted to delete it but the file does not exist at the given location. Does anybody have an idea what I could do to resolve this? By the way, the App shows up in Application Manager but can't be deleted or executed. It just says: not installed.

I had the same problem and I solved it by using the command prompt.
In the command prompt go to the file where adb exist in C:\Program Files (x86)\Android\android-sdk\platform-tools) and also you must put the de.tradino_shop.pinkweather-Signed.apk file in that folder (you will find it in the debug file of your project) then just in the command prompt execute this line: adb install -r de.tradino_shop.pinkweather-Signed.apk
After installation finish just clean your project and debug again. Your android phone must be connected to your PC and is on USB debugging mode.

Try to go to Settings -> Apps -> All Apps. The path may be different but you need to check the list of all the installed apps and see if your app is in the list. if it is in the the list than uninstall it for all the users.

Related

Xamarin Android install flags

I'm building an Xamarin android admin app meaning that the app will be the device admin but in order to be able to uninstall the app while developing I need to add to the android manifest android:testOnly="true"
but then it fails at deployment I get the following error
Mono.AndroidTools.InstallFailedException: Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]
and to avoid that error I need to pass an install flag with adb as written this stack overflow answer
how do I do that in VS.
First of all, please archive your application then export the xxx.apk file. Note: when you archive your application, please notice following settings.
unselect following settings
select following settings.
For example, I archive my application to root path of F desk like following screenshot.
Then, open the adb command to click the icon like following screenshot.
Enter the F: in the adb console. Then enter the adb install -t -r com.companyname.app25.apk like following screenshot(please make sure your android emulator is running).
In the end, you will found your apk file was installed.

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.

Installation error: INSTALL_FAILED_UID_CHANGED no root

I have checked all the solutions, comments and answers of all other questions in StackOverflow.
I have been running, compiling and debugging my app for months. But suddenly it started to appear this message in my Eclipse when using my Nexus to play with it.
MOBILE:
I have no root !!! (It's a Nexus, and I have no root, and all the answers in other Stackoverflow's questions need root to be executed)
The application is uninstalled, there's no trace of it in "Applications"
Since I don't have root access, I can not access to /data/data folder, or /data/local, or /data
I do know problem would be solved resetting the phone to factory settings, but, sincerely, I can not.
ECLIPSE:
I have cleaned the project many times, restart Eclipse and even update it
I can not change the name of the project (as one solution suggests), since it's a long time project and I can not change it
Console says:
Installation error: INSTALL_FAILED_UID_CHANGED
Please check logcat output for more details.
Launch canceled!
Logcat says:
01-05 12:18:19.265: W/ActivityManager(761): No content provider found for permission revoke: file:///data/local/tmp/MyApp.apk
01-05 12:18:20.855: W/PackageManager(761): Package couldn't be installed in /data/app/com.myapp-1.apk
I can install, uninstall other APK/applications with no problems at all. So it's not about permissions in /data folder/subfolders
CONSOLE:
If I try to uninstall (with -d or any other parameter) the app it says: "Failure" (because adb does not find the app in the phone)
So, I'm not debugging with virtual machine / emulator. I have a Nexus no-rooted with no trace of the application, and I can not build the app from Eclipse to the device.
Thank you
I had the same issue in my non-rooted Nexus 5. I managed to solve it without root access nor Factory reset.
For this device, I managed to solve it by going to Settings -> Storage -> Misc and try to delete any files related to the faulty app (in my case, an .apk that was pushed from Android Studio and a .db file). I also clicked on Cached data to wipe the cache for all apps.
I don't know exactly which of the two things triggered the solution. You probably want to try to delete some files in Misc before wiping the cached data, since it seems less of an overkill.
It seems to be that there were some remaining files from a previous installation which weren't wiped with the uninstall (probably an issue in the Android installation system). These files aren't accessible without root access, since they are under the /data/local/ folder. Apparently the Storage tools for the Nexus 5 have permission to delete files under that folder.
I don't know whether other devices have a similar set of storage tools.
Downloading app from play store will resolve the issue.
To continue development on the app, uninstall the currently installed app and just launch the app from eclipse.
It works fine.
This may seem odd, but my pointy-haired boss just had this issue and tried everything we could think of. Just would NOT install due to the INSTALL_FAILED_UID_CHANGED error.
He uninstalled some other apps (games) and suddenly it would install. Maybe it is an issue of disk space on internal card? Dunno, but worth a try when someone else hits it.
First time this happened I tried installing from eclipse, from command line etc....
Everything failed so I did a factory reset which then worked.
24 hours later it happened again.
Not wanting to do another factory reset, I tried all the same things again to no avail.
Lastly I tried downloading our current app from the appstore, which miraculously worked.
I then used adb to reinstall.
So if you have a version of your app in the app store, try installing that to get something on your phone, then do a reinstall "adb -d install -r $PACKAGE.apk
Hope this helps someone.
This (or some other magic) helped me:
adb shell pm clear MY_PACKAGE_NAME
I can solve this like below without rooting on my Nexus 5.
Push your app to /sdcard/
adb push test.apk /sdcard/
adb shell
adb shell pm install -l /sdcard/test.apk
-l option means - pm install: installs a package to the system. Options:
-l: install the package with FORWARD_LOCK.
Here are some other things to check/try that are safe to do:
Make sure your package name is 100% unique and not colliding with
another app. You could temporarily change it to test.
Try powering your phone off and then back on to clear
data caches.
Try a soft reset for your device (which might be the
same as powering off/on).
Try deleting Cached Data under Settings -> Storage, this will clear all cached App data at once, but it does the job (in my case)
This is because of if you have install the app with same package name. So try to remove that one.
I could only fix this by rooting. I know you don't want to do that, but it worked for me. I downloaded Titanium Backup then found my uninstalled app crossed out in the list on Titanium Backup. I couldn't get rid of that crossed out one until I went to Batch Actions then Remove orphan data. That allowed me to re-install my app and it worked well.
This worked for me:
adb install -l -r <'apk_name'>.apk
-l = forward lock
-r = reinstall
I had this exact same problem. What finally worked for me was to change the applicationId (your package name) in build.gradle to something different, then rebuild the project, and voilĂ , successful deployment.
What led to this situation was that I'd copied an existing Android Studio project into a new one, and was working off of that new one. The thing is, I'd never deployed the original apk on my device before, and was only trying to deploy the new copy of the app.
I was using a device that was just for testing, so I just reset the whole device. It worked for me anywho.
This solution worked for me:
Put your APK to the device's storage/sd card
adb shell pm install -l -r "/sdcard/<apk_filename>.apk"
-l = forward lock
-r = reinstall
For no root Device you need you need to delete the app from the app list in the device:
go to "settings"
go to "storage"
on third tab "downloaded apps" locate your app
you can delete it from there
Works for me!
In my case changing the package name of the GCM signature worked. since it uninstalls the complete package.
For more detailed explination click here
<permission
android:name="com.androidcodelab.sampleproject.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.androidcodelab.sampleproject.permission.C2D_MESSAGE"/>
Package name of the project changed to :
<permission
android:name="com.androidcodelab.xyz.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.androidcodelab.xyz.permission.C2D_MESSAGE"/>
and then I reverted back to the actual package name
For android studio go to File-> Project Structure -> app -> Flavors and your right side you will see Application Id field just change Application Id and you are ready to go... :)
Go to Run/debug configurations.
Under Android App delete "app".
Then add another configuration under module: app
For me the only way was to root the phone and clear /data/data/ directory. Here are the steps:
1. Open web browser on mobile device
2. Open website: https://towelroot.com/
3. Click on lambda sign to download Towerl Root and install it afterwards
4. Open Towel root app and click on button "make it rain". If it says: "device not compatible" google other wait to root the device.
5. Download SuperSU app from Play Store
6. Download Terminal Emulator app from Play Store
7. Run Terminal Emulator
8. Type following command in terminal emulator:
su
9. Allow superuser access for terminal emulator
10.Type following command in terminal emulator, substitute 'package_name' with your app's package name:
rm -r /data/data/package_name
I tried all above and NADA!
the ONLY way it works for me (NON ROOTED DEVICE) was:
1.- Change on Project structure [Ctrl+Alt+Shift+S]->Flavors: the Application Id, for example:
'com.example.something' to 'com.example.somethingxx'.
(which is the same as changing on the build.gradle file)
2.- Refactor package name of the project to the SAME NEW NAME you used on Application Id: 'com.example.somethingxx'
This will ensure you are installing a new App on the device... let me know!

Unable to install apk in android emulator

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.

Categories

Resources