Xamarin Android install flags - android

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.

Related

Xamarin Android Deployment failed because of an internal error

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.

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.

Android Studio run app/test directly if nothing is changed

If nothing is changed since last compile and run, and then I hit run again (green start button), it complies and then run.
How can I make it run directly without compiling the same thing?
I might be wrong, I don't think but it's possible when you pass by Android Studio, but by using the build apk and install it with Android Debug Bridge (ADB), you should get the desired behaviour.
When the project compiles, AS creates an output apk. Usually, this should be named app-debug.apk and located in build/outputs/apk/ folder:
Your .apk file (signed with either a release or debug key) is in your module build/ directory after you build your application.
cf. Running on emulator
By using adb, you'll be able to install this apk previously generated (and I believe, without compiling again) on the device with the command install:
$ adb install -r path/to/app-debug.apk
Once installed, you should retrive the command to launch your application. A little research bring me to "How to start an Android application from the command line?":
$ adb shell
$ adb am start -n my.package.name/my.package.name.MyActivity
And then, you could combined them on same line to launch the apk just right after its installation. This looks like:
$ adb install -r path/to/app-debug.apk && adb shell am start -n my.package.name/my.package.name.MyActivity
Therefore, you application will run without compiling.
First try right click on the project and then select Run As Android Application. This will change you app default run configuration.
If this does't work then try to change it's run configuration from right click on project in project explorer and select Run as -> Run configurations.
Always run your project if you have opened that projects java class tab in workplace. You cannot run your project directly by clicking Green play button if you opened a XML file of that project. However you can run a project if you have opened manifesto of that project.

INSTALL_FAILED_SHARED_USER_INCOMPATIBLE while using shared user id

I am working on Android application which will share the database. For that, I'm using android:sharedUserId in both application's Manifest file. When I am trying to run the application after adding that sharedUserId it shows me following errors in console.
[2013-03-04 19:37:32 - MainActivity] Installation error: INSTALL_FAILED_SHARED_USER_INCOMPATIBLE
[2013-03-04 19:37:32 - MainActivity] Please check logcat output for more details.
[2013-03-04 19:37:32 - MainActivity] Launch canceled!
Please help me to resolve this problem.
Follow these steps to fix the INSTALL_FAILED_SHARED_USER_INCOMPATIBLE error:
Remove the existing application (if it was already installed)
Remove the sharedUserId from AndroidManifest.xml
Rebuild the application
Reenter the sharedUserId to AndroidManifest.xml
Rebuild the application (one more time)
This means something about your app was not correctly uninstalled. This steps help to force uninstall from internal commands:
Connect your phone to PC with usb
From your shell launch:
$ adb shell
shell#android:/ $ su
shell#android:/ # pm list packages | grep <part of package>
package:com.android.providers.applications
package:com.android.providers.calendar
package:com.android.providers.contacts
package:com.android.providers.downloads
...
shell#android:/ # pm uninstall <package>
shell#android:/ # exit
shell#android:/ $ exit
$
Basically, you log into android shell, become superuser, find problematic packages, and uninstall it
In my case, the two app was signed with differents signatures. Using the same signature fix my problem
The solution for me was to select the "Build > Clean Project" menu option. It took a long time but the application deployed once it was complete.
Although you have accepted answer, I also want talk my situation which I met this error. My project is a Launcher which just happen to use some system grant like, Manifest.xml have two item:
<uses-permission android:name="android.permission.STATUS_BAR" />
or
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
and console log out:
Error using StatusBarManagerService - java.lang.SecurityException on android.permission.STATUS_BAR
Lastly, my colleague give me a hint using "platform debug key", I am not sure this will be suitable for you, but for another guys possibility for this kind question.
The below picture is my solution:
screenshot from project structure
you might also notice 'Signing Config' of "Flavors" and "Build Types", you might choose 'Name:' of "Signing".
Simply delete the existing application from mobile and reinstall using run.
my issue was having a second instance of the app installed via Samsung Secure Folder! One I uninstalled it there too, my issue went away.
In my case, I had two build variants (one specific for a device, and one general).
I was running the device-specific build on an emulator when this error showed up.
I did a slightly different approach.
My work involves using a modified Android OS along with a modified adb tool. The app (app1) I am working on "shares a user" with another app (app2) by another team. In order for me to get the Android Studio debugger to work, I had to follow these steps in order:
use the Build (from Android Studio Menu) -> Generate Signed APK
build a debug version of apk (app1) with the key store information used by (app1 and app2)
use adb to uninstall the previous apk
use adb to install the signed debug-apk
use adb to launch the app in debug mode
connect the Android Studio debugger to the app
I have encountered the same problem. I tried out everything, but unfortunately, nothing works for me. As it's a testing device no hesitated to do a factory reset. Oops. sucks didn't work either. Invalidate Cache/ Restart did the trick eventually. Looks like it's an Android Studio 3.5 bug.
Thanks.
I was using Emulator and the solution for me was to select the "AVD Manager" and Wipe all data from my Emulator device. After that application was installed.

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