ADB apk installation error "INSTALL_FAILED_INVALID_URI" - android

I use ADB tool and I want to install apk on my emulator. So I use this command
adb install /home/jody/myexample.apk
and I got this error
2841 KB/s (242867 bytes in 0.083s)
pkg: apk
ver: /data/local/tmp/concolicexample.apk
Failure [INSTALL_FAILED_INVALID_URI]
I search this error and from https://mobiledevstories.wordpress.com/2013/06/03/android-adb-install_failed_invalid_uri/ I found out I should The solution is to change permissions to directory but the problem is I don't know where is /data/local/tmp and where should I change permissions?
I should mention that I use genymotion emulator on Linux.
please help me. Sorry if this problem is really primitive. I just begin to use adb.

There are more people with your problem here:
Cannot install package on rooted device : INSTALL_FAILED_INVALID_URI
I think that your device needs to be rooted for this to work, or you won't have sufficient rights. I don't have a rooted device here so don't remember if all steps are necessary:
So the /data/local/ directory is on the Android device, so using adb you need to access the device.
1) adb remount (This might not be necessary, this gives you more access rights to the device)
2) adb shell <- opens a shell on the device instead of your computer.
3) chmod 777 /data/local/
4) chmod 777 /data/local/tmp/
Hopefully it works for you!

Related

Phone is rooted but can't pull files from /data/data folder

My phone Samsung Galaxy S5 mini is rooted. I'm trying to pull files from /data/data/myapp.package/ to folder on my PC.
adb pull /data/data/myapp.package E:\myapp\myapp.package
it gives me this error
adb: error: failed to copy '/data/data/myapp.package' to 'E:\myapp\myapp.package': Permission denied
I found many questions like mine but no answer solved my problem. Some suggested to execute this command adb root before pulling files. Some suggested to install adbd insecure app to enable root access. In fact after installing that app, phone disappeared from adb terminal. Both solution didn't work for me.
BTW, I can copy files using cp command from adb shell but I have to copy files to sdcard and then pull from sdcard. I'm looking for solution which allows me to copy files directly from /data/data/myapp.package to my PC
Any solution?
For your adb to be able to access /data/data directly (for adb pull), your adbd should be running as root - which can generally be done by adb root command.
adb root would not work on commercial devices like Samsung Galaxy S5 mini as commercial devices have ro.secure=1, i.e., the adbd can't be restarted as root due to a check of property called ro.secure. adbd insecure app circumvents this and restarts adbd in root mode to enable adb pull, etc. to work.
In short, if adbd insecure app doesn't work for you, it's not possible to do adb pull from /data/data in your existing ROM. It might be possible if you change the ROM / do some boot.img tweaks, but I would probably suggest trying latest version / different versions of adbd insecure app before going for ROM changes.
Read more on rooting here.
First you need to hit these two command from command line
adb root
adb remount
then
adb pull /data/data/myapp.package E:\myapp\myapp.package
This is my example pulling DB file from the root directory
adb -e shell "run-as com.example.project cp /data/data/com.example.project/databases/project.db /sdcard"
The key is run-as
Here's a one-liner that lets you pull a file without installing anything else and without having to copy it to a public location on the device to then pull it to your computer:
adb exec-out su -c cat /data/data/myapp.package/my_file.apk > my_file.apk
What this does:
adb exec-out runs a command and outputs the raw binary output
su -c runs the provided command as root
cat <file> prints out the file contents
> <file> redirects the output from adb (i.e. the raw file contents) to a local file.

How to make system partition in AVD in emulator writable

This is fairly a very old question but I am surprised that none of the solutions are working for me. I need to run an android app as system app in an AVD (in emulator) created for Android version 7.0. For this, I want to push apk file to system partition but I keep getting error saying it is read only file system. I found many similar questions on stackoverflow but nothing is working for me. I restarted adb in root, executed it with remount as suggested in answers to similar questions, but system partition file system permissions do not change. Here is a sample session:
mvsagar#mvslt:~/sw/android_sdk/platform-tools$ ./adb root
restarting adbd as root
mvsagar#mvslt:~/sw/android_sdk/platform-tools$ ./adb remount
remount succeeded
mvsagar#mvslt:~/sw/android_sdk/platform-tools$ ./adb push /home/mvsagar/projects/AndroidStudioProjects/LcnApps/app/LCNUE.apk /system/app/LCNUE.apk
adb: error: failed to copy '/home/mvsagar/projects/AndroidStudioProjects/LcnApps/app/LCNUE.apk' to '/system/app/LCNUE.apk': couldn't create file: Read-only file system
I have tried manually remounting with read/write(rw) options using adb shell, but the remounting fails.
Is there any way to have read/write permission on system partition?
My dev env is Android Studio on Ubuntu.
In my case, I use a avd( Based on: Android 8.0 (Oreo) Tag/ABI: google_apis/x86_64 ).
$ emulator -avd Nexus_5X_API_26_APIs -writable-system
$ adb root
$ adb remount
Then, /system is writeable.
$ adb push somefile /system/bin/ is work.
When working with Q, this is the only solution that worked for me: https://stackoverflow.com/a/64397712/1898527
Adding here the steps for completion (kudos to the original author):
> emulator -avd Pixel_3a_XL_API_29 -writable-system
> adb shell avbctl disable-verification
> adb disable-verity
Now reboot your emulator so that the changes take effect.
> adb root
> adb remount
> adb shell "su 0 mount -o rw,remount /system"
Note: you will need an emulator without Google Play, otherwise this won't work. You can get it by following the steps described here: https://stackoverflow.com/a/45668555/1898527
use genymotion emulator, which is faster, light weight and pre rooted. (which means you can access system directory)
For the benefit of others, answer to the question was answered a long ago by #Ishamael in another stackoverflow question Read only file system on Android

Is it possible to Root Visual Studio Emulator Android?

I am currently using 'Visual Studio Emulator for Android' to run android apps on my computer, i find that after using multiple types of emulators bluestacks, genymotion, andy etc. That VS is the most stable and easy-to-use out of them all.
The only problem that i have compared to the other emulators is running apps that require root permission, with this being an emulator i know that its not possible to go the route of rooting via fastboot/recovery, this is the only method i know of rooting as thats how i normally do it on my phone.
I have tried most of the 'rooting' APK's (kingo,towel,frama etc) and none of those have worked.
So would anybody happen to know how i can get root access on Visual Studio Android Emulator?
I am trying to run a touch-replication app (Frep & RepetiTouch) but all of them seem to require root access.
Any advice would be much appreciated. Thanks
Yes, you can. Here are some basics before the steps. Fundamentally all Visual Studio Emulator has root access; if you do adb shell you will get a root prompt. The only thing that is missing is the su binary and access for applications to connect to root shell through su. You can get the su binary from superuser apk from clockworkmod and the access to the root shell through the su daemon.
Installing su binary
Download superuser apk from clockworkmod. Ideal way is to download the app from google play store and navigate to /data/app/ and copy com.koushikdutta.superuser to your pc through adb pull /data/app/com.koushikdutta.superuser <local_path_in_your_system>
Change the .apk extension to .zip.
Navigate to assets/x86/ and copy the su binary to /system/xbin in your emulator
adb push <location_of_su> /system/xbin
chmod with suid and rwx
adb shell
chmod 6777 /system/xbin/su
symlink to /system/bin
ln -s /system/xbin/su /system/bin/su
Run the su daemon
/system/xbin/su --daemon
Giving Access to Applications through su
Install the superuser binary by either dragging and dropping into
the emulator or using adb install <path_to_superuser_apk>
Download rootchecker free\basic or even a terminal emulator for that
matter. We just want to check if our device is rooted.
Run the rootchecker app to check root and you should be able to get
the prompt from superuser.

How to solve ADB error [INSTALL_FAILED_UID_CHANGED] on non-rooted phone?

I get the error using the Android Studio (but I get the same if I use ADB from command line).
Every solution I found says that I need to delete the installation folder on the phone:
adb shell rm -r /data/data/com.example.my
but I get a permission denied error.
So what can I do on non rooted device?
(I can't delete the folder from device file browser, the folder /data is empty)
The app is not listed in the Android app manager
adb uninstall com.example.my
gives
Failure
Unfortunately the only fix I have found for a non-rooted phone is to wipe the device and start again. The reason this is happening will be because the folder still exists with one file that wasn't deleted.
Try this out
adb shell pm clear MY_PACKAGE_NAME
or maybe this:
adb install -l -r <'apk_name'>.apk -l = forward lock -r = reinstall
Why don't you uninstall the app using:
adb uninstall com.example.my
This question is related: Android INSTALL_FAILED_UID_CHANGED

ADB error=13, Permission denied from ADB, exists=true - Android SDK Setup

This is a recurrent question, and it seems it has several reasons. I cannot discover mine, even after googling. Several people had answered this question, though.
The problem is that when I try to run an android project with Eclipse and ADB, I get:
Failed to get the adb version: Cannot run program "/extraHD/android/android-sdk-linux/platform-tools/adb":
error=13, Permission denied from '/extraHD/android/android-sdk-linux/platform-tools/adb'
- exists=true
Some data:
1) /extraHD is my second HD, 180GB free, where I have full permissions
2) adb executable has full permission 777
3) If, after 'cd /extraHD/android/android-sdk-linux/platform-tools', I run any of these (no adb process running):
./adb
./adb shell
./adb start-server
./adb kill-server
./adb shell kill you
./adb root
./adb remount
I get the very same answer:
bash: ./adb: Permission denied
And same answer when executing as root! I can create/delete files in that directory, even as a normal user...
Same problem after reinstalling ADB, both through Eclipse and zip file.
Rebooting didn't work either.
I get the same problem with /extraHD/android/android-sdk-linux//tools/emulator.
Tried fsck, reinstalled Eclipse, reinstalled Tools and Platform-tools (adb in particular), reinstalled the APIs. Same thing.
Clues??
I had a similar problem and I solved it by doing the following (mounting the sdk partition at boot time and changing permissions in fstab in order to allow writing in Windows NTFS partition):
Open a terminal, you can use Ctrl+Alt+t
Use 'blkid' to list the block devices and print the universally unique identifiers (UUID)
sudo blkid
Locate the line with the label of your SDK partition and copy the UUID value:
/dev/sXX: LABEL="secondHD" UUID="copy_this" TYPE="ntfs"
Add a new line at the end of the fstab file so the partition will be mounted during boot:
sudo gedit /etc/fstab
Remember to customize the "your.." values, the order it's important, fields on each line are separated by tabs or space; type man fstab for further information). Save and exit.
UUID="yourValueCopied" "yourPartitionPath&Name" ntfs users,uid="YourGroup",gid="YourUserGroup",umask=0022,exec,permissions,auto 0 2
Restart the computer and try another time adb :)
Seems that It's a ntfs partition issue:
https://askubuntu.com/questions/207180/changing-permissions-in-fstab-in-order-to-allow-writing-in-windows-ntfs-partitio
A very good explanation of fstab-permission-masks:
http://www.omaroid.com/fstab-permission-masks-explained/

Categories

Resources