Valgrind - adb push failed to copy vgdb - android

I'm trying to install valgrind on my android device, but when i try to execute adb push Inst /
i get an error
C:\VmFiles>adb push Inst /
push: Inst/data/local/Inst/bin/vgdb -> /data/local/Inst/bin/vgdb
failed to copy 'Inst/data/local/Inst/bin/vgdb' to '/data/local/Inst/bin/vgdb': N
o such file or directory
Ofc file vgdb exists in this directory
C:\VmFiles>ls Inst/data/local/Inst/bin
callgrind_annotate cg_diff valgrind vgdb
callgrind_control cg_merge valgrind-di-server
cg_annotate ms_print valgrind-listener

after some observation i found there is no directory Inst/bin in local
so first you need to make a directory in /data/local/Inst/bin
and for that you need root access to your device because you cant access /data/ directory without root permissions
then do following steps.
first go to directory where vgdb is placed then
execute
adb push vgdb /data/local/Inst/bin/

Syntax for adb push :
adb push <PATH_OF_FILE_ON_HOST> <PATH_OF_FILE_ON_DEVICE>`
Since you are trying to push from Inst/data/local/Inst/bin/ path. Use the below command with absolute path.
adb push /full/path/to/Inst/data/local/Inst/bin/ /path/on/device/test_folder/
This should push all (both files and directory) content of the directory Inst/data/local/Inst/bin/ to /path/on/device/test_folder/
Make sure /path/on/device/test_folder/ exist, or run below command before hand.
adb shell mkdir /path/on/device/test_folder/
Use adb shell ls /path/on/device/test_folder/ to list, if your files are transferred to the device.
Also make sure you have permission to write to /path/on/device/test_folder
Note: You will usually have permission to write to /sdcard/ but again will require root permission to assign execute permission (chmod) to the transferred binary.
In this case, may need to root the device.

Related

ADB push error: failed to copy: Not a directory

So I'm just trying to modify the hosts file on a family members phone. I've put the phone in debug mode and pulled the hosts file, edited it, but when I try to push it I get the message, "adb: error: failed to copy 'D:/hosts\hosts' to '/system/etc/hosts/hosts': remote couldn't create file: Not a directory"
Here's the commands I've used:
adb pull /system/etc/hosts D:\hosts
/system/etc/hosts: 1 file pulled. 0.0 MB/s (56 bytes in 0.003s)
adb push D:\hosts /system/etc/
adb: error: failed to copy 'D:\hosts\hosts' to '/system/etc/hosts/hosts': remote couldn't create file: Not a directory
This is my first time using android debugging/adb and nothing else I've read helped. Thanks in advance.
EDIT: So I've made a little progress. I realized that the hosts file is not in a hosts directory, so I changed it to adb push D:\hosts /system/etc which still didn't work, but adb push D:\hosts\hosts /system/etc gave me the response adb: error: failed to copy 'D:\hosts\hosts' to '/system/etc/hosts': remote couldn't create file: Read-only file system So it looks like my problem is now in adb shell chmod
EDIT2: So after some more research I came across this Read only file system on Android. When trying mount -o rw,remount /system I get mount: '/dev/block/dm-0' not user mountable in fstab. In the mounts file /dev/block/dm-0 is on /system. The new problem is fstab is not located in /etc
EDIT3: It looks like my big problem is I have to root the phone I think. I don't have su or sudo to do the remount. Seeing as it's not mine, I don't want to root the phone.

ADB Backup - location of the resulting file?

I used an adb command to backup a file in data/data of an Android phone. After the command ran, my phone said it was successfully backed up, but where is the backup file?
If you use adb backup -all command then it will create backup.ab file in the current working directory.
If you want to specify path use -f like below
adb backup -f <path_to_backup_file> -all
So if you run
adb backup -noapk com.masimo.merlin.consumer
then backup.ab gets stored in the present working directory by default.
In unix/linux, you can know your present working directory by typing pwd and in windows you can know it by typing cd
More Info about backup

Why does data folder in android simulator deny permission?

I tried to create database file into
C:\Users\cammm\AppData\Local\Android\Sdk/platform-tools/data/data/com.cookandroid.cammm
Here are steps that I tried to get into the folder
click on "cmd" and run as administrator
cd C:\Users\cammm\AppData\Local\Android\Sdk/platform-tools
adb root
adb shell cd /data/data/com.cookandroid.cammm
Now this pops up: "/system/bin/sh: cd: /data/data/com.cookandroid.adb: Permission denied"
I used "ls" in "platform-tools" folder and saw that it was
"drwxrwx--x 37 system system 4096 2018-07-18 15:46 data"
which means file can only execute but not write or read in others.
using chmod did not work. (chmod: chmod '/data/data/com.cookandroid.adb' to 40702: Operation not permitted)
run as administor does not work
What should I do?
You will only be able to access the data/data folder if the device which you are accessing is rooted. when you have the device rooted then it will show # as prompt on the command line. so Make sure you have the rooted device to execute the above steps.
Please note: It's not advisable to use the rooted devices to carry out any function of the application as it's simply a hack of the device so you have to understand the risk associated with it.

Use adb pull to copy app's file from phone (not rooted)

I am using a MacBook as my development machine. My Android phone is not rooted. I want to copy my Android app's file from phone to my MacBook. I tried the following:
Connect Android phone to MacBook (Developer's option is enabled)
adb pull /data/data/com.my.app/app_data/data ~/Documents/my/app/
where /data/data/com.my.app/app_data/data is the file path on phone, and ~/Documents/my/app/ is the directory path on MacBook.
But the above adb pull command shows Permission denied.
I also tried to use su under adb shell, but it doesn't work either:
~$ adb shell
shell#xyz:/ $ su
/system/bin/sh: su: not found
So, how can I copy my app's internal file to my MacBook directory?
On a non-rooted phone you can not access the app private data directory (/data/data/com.my.app).
The only way to extract the data is to create a backup of the app data using adb backupp:
adb backup -f mybackup.ab com.my.app
For extracting the information from the created backup archive you can use the Android Backup Extractor. It converts the Android backup archive to a tar archive file.
Note: If the app specifies in it's manifest that backup is disallowed the described way does not work. In such a case the only way is to root the phone.
You have to navigate to your file with adb shell.
Then copy to sdcard:
cat yourfile > /sdcard/yourfile
Then exit from adb shell and now you can pull:
adb pull /sdcard/yourfile

How to use adb command to push a file on device without sd card

How to push a file from computer to an Android device having no SD Card in it. I tried:
C:\anand>adb push anand.jpg /data/local
3399 KB/s (111387 bytes in 0.032s)
C:\anand>adb push anand.jpg /data/opt
3199 KB/s (111387 bytes in 0.034s)
C:\anand>adb push anand.jpg /data/tmp
3884 KB/s (111387 bytes in 0.028s)
Above commands to move a file anand.jpg to a device but I didn't get this jpg file in the device.
I didn't get any success result on cmd prompt, I only got:
3399 KB/s (111387 bytes in 0.032s).
From Ubuntu/Mac Terminal, the below command should work.
./adb push '/home/hardik.trivedi/Downloads/one.jpg' '/data/local/'
For adb v33 and above if you are getting a permission denied error, try what I tried. The following command and it works fine.
The only caveat is you might need to use tmp directory on such an emulator.
adb shell //Entering into shell
su //Super user mode
chmod 777 /data/local/tmp/ //Grantint RWX access
exit
chmod 777 /data/local/tmp/ //Grantint RWX access
exit
And then try
./adb push '/home/hardik.trivedi/Downloads/one.jpg' '/data/local/tmp/'
I did it using the push command, which has syntax:
adb push filename.extension /sdcard/0/
Example of copying directory, and sub-directory content:
adb push C:\my-location\data\. /storage/emulated/0/Android/data
Note that push did just hang in latest platform-tools (33.0.1, at time of writing) for a certain amount of files, beside the adb.exe suddenly taking 5MB+ instead of 1.5MB, hence I just did replace the adb.exe with one I had from 28.0.0 version of platform-tools (I did not downgrade the entire platform-tools, because adb.exe is kind of stand-alone).
I don't say there is any conspiracy around data folder,
But my Samsung device puts limits on my USB file transfer, beside Android v11+ not allowing access to data folder anymore, hence I needed above command to work with 100% speed (without hanging one hour for little more files).
Follow these steps :
go to Android Sdk then 'platform-tools' path on your Terminal or Console
(on mac, default path is : /Users/USERNAME/Library/Android/sdk/platform-tools)
To check the SDCards(External and Internal) installed on your device fire these commands :
1) ./adb shell (hit return/enter)
2) cd -(hit return/enter)
now you will see the list of Directories and files from your android device
there you may find /sdcard as well as /storage
3) cd /storage (hit return/enter)
4) ls (hit return/enter)
you may see sdcard0 (generally sdcard0 is internal storage) and sdcard1 (if External SDCard is present)
5) exit (hit return/enter)
to come out of adb shell
6) ./adb push '/Users/SML/Documents/filename.zip'
/storage/sdcard0/path_to_store/ (hit return/enter)
to copy file
Sometimes you need the extension,
adb push file.zip /sdcard/file.zip
run below command firstly
adb root
adb remount
Then execute what you input previously
C:\anand>adb push anand.jpg /data/local
C:\anand>adb push anand.jpg /data/opt
C:\anand>adb push anand.jpg /data/tmp
After Trying all the answers this worked for me
Where I am Pushing a file on Desktop to Android Device (Redmi K20 pro) connected Over the air using adb.
This command pushes the file to the downloads folder on my phone
adb push ~/Desktop/notifications.drawio ./storage/emulated/0/Download
after running this if you get a permission denied error
try running these commands in order (which basically changes the directory permission)
adb shell
chmod 777 /data/local/tmp
exit
and then run try the adb push command
I have documented this here feel free to share your views and help improve it.
Try this to push in Internal storage.
adb push my-file.apk ./storage/emulated/0/
Works in One plus device, without SD card.
My solution (example with a random mp4 video file):
Set a file to device:
adb push /home/myuser/myVideoFile.mp4 /storage/emulated/legacy/
Get a file from device:
adb pull /storage/emulated/legacy/myVideoFile.mp4
For retrieve the path in the code:
String myFilePath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/myVideoFile.mp4";
This is all. This solution doesn't give permission problems and it works fine.
Last point: I wanted to change the video metadata information. If you want to write into your device you should change the permission in the AndroidManifest.xml. Add this line:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
I've got a Nexus 4, that is without external storage. However Android thinks to have one because it mount a separated partition called "storage", mounted in "/storage/emulated/legacy", so try pushing there: adb push anand.jpg /storage/emulated/legacy
As there are different paths for different versions. Here is a generic solution:
Find the path...
Enter adb shell in command line.
Then ls and Enter.
Now you'll see the files and directories of Android device. Now with combination of ls and cd dirName find the path to the Internal or External storage.
In the root directory, the directories names will be like mnt, sdcard, emulator0, etc
Example: adb push file.txt mnt/sdcard/myDir/Projects/
This might be the best answer you'll may read.
Setup Android Studio
Then just go to view & Open Device Explorer.
Right-click on the folder & just upload a file.
In Mac: To push files via adb
adb push /Users/Downloads⁩/amazon.sdktester.json '/mnt/sdcard/amazon.sdktester.json'
You are trying to write to system folders. With ADB you have root (admin) access so you see the system folders of which sdcard is one of them so to send a picture you could use
D:\Program Files\Android\sdk\platform-tools\adb push am files\android sdk\adb.exe push C:\Downloads\anand.jpg /sdcard/pictures/
NB: C:\Downloads\anand.jpg replace with path and name to picture..
Certain versions of android do not fire proper tasks for updating the state of file system.
You could trigger an explicit intent for updating the status of the file system.
(I just tested after being in the same OP's situation)
adb shell am broadcast -a android.intent.action.MEDIA_MOUNTED -d file:///
(You could pass a specific filepath instead of file:/// like file:///sdcard )
In my case, I had an already removed SDCard still registered in Android.
So I longpressed the entry for my old SDCard under:
Settings | Storage & USB
and selected "Forget".
Afterwards a normal
adb push myfile.zip /sdcard/
worked fine.
To push all the files at your directory to the Android device use:
PS D:\myFiles> adb push . '/data/local/tmp/'

Categories

Resources