Android: adb pull command not working/stuck - android

on Linux machine I'm able to push files to my Motorla one zoom XT2010-1 via adb yet when I try to pull, the command is stuck indefinitely. The paths seems to be correct since TAB autofill kicks in, and file is created in destionation directory.
adb pull /sdcard/Download/magisk_patched-25200_QsXC2.img /home/flap/Downloads/

Related

How I can pull files from my Android Sony Xperia Z1 using ADB tool? P.S My phone is rooted

I tried on my own but failed , when I looked around I didn’t find except tool called adbd insecure which make me can run this command
“adb root”.
when I run this command I got no response on CMD and when I tried to use this program mentioned above on my phone I got an error.
when the desired action when I run the command "adb root" om my Windows 10 OS
is "adbd is already running as root" in CMD.
So far I can run "adb pull /data/data & put it everywhere on my PC".
Any help please.
Okay, so here are the steps that works for me.
I'm a Linux user so you can later convert terminal commands to windows if necessary:
Since you mentioned that your device is already rooted:
adb devices--> Make sure your device is connected.
adb shell--> runs shell command on your device.
su --> gives you root access.
cd data/data --> (data/data/xyz) is apparently the file you want to pull).
pwd--> will display the path.
copy that path and save it somewhere.
use "exit" to get out from the shell.
Once you are back in C:\Program Files (x86)\Android\android-sdk\platform-tools, run adb pull (paste the path that you copied).
Now you should have your file. Hope that helps.

Removing an sqlite db in Android

I'm debugging my android app in Android Studio using a real android device and. I see that the Sqlite db path is
/data/data/com.my_app/databases/data1.db
I want to remove it. By that path doesn't exist when try to find it by a file manager. And, of course, this isn't working:
adb -e shell rm /data/data/com.my_app/databases/data1.db
adb server is out of date. killing...
* daemon started successfully *
error: device not found
So how can I remove it and why isn't it visible in my smartphone?
why isn't it visible in my smartphone?
Because it is on internal storage, which you do not have access to, except on emulators and rooted devices.
And, of course, this isn't working:
That is some separate problem with adb running on your machine.
So how can I remove it
If you want to completely clear your app's data (databases, SharedPreferences, and other files) on internal storage, use the Settings (e.g., Settings > Apps > (your app) > Clear Data on Android 4.x/5.x).
If you specifically want to get rid of this file on an emulator, the command you tried should be fine. I suggest restarting the emulator.
If you specifically want to get rid of this file on production hardware, you will need to use run-as:
adb shell run-as com.my_app rm /data/data/com.my_app/databases/data1.db
You can't reach that directory if your device isn't root . For change or modify system files you must have root access .

how could I transfer file from terminal to screen /dev/tty.*(android machine)?

I'm developing android set-top box app.
So, I have android box and its adb is REALLY SLOW.
When I have to install .apk file to debug my project, I use adb connect [ip address] via wifi and then build & run with Android Studio because the set-top box doesn't have USB port.
But it has serial port so I can connect its shell by screen /dev/tty.usb-serialblablabla 115200. when I use that command, I can see exactly same screen as one of adb shell.
Its adb shell(via wifi) shows very very slow performance.
For example, if I want to run pm list packages, I should type 'pm list packages' and wait for 2min.and then type enter key.(...sigh)
Whereas,Using screen /dev/tty.* methods respond promptly.
I don't know where this difference is come from.
but it is not matter of wifi. I checked its speed. it is quite normal.
In this circumstance, I click Run button in Android Studio after adb connect.
gradle build takes about 10sec.
upload .apk(10.2mb) takes about 10min (sigh).
Because screen ... way is much faster then adb connect way, I want push my .apk into device via 'screen'. how can I do? OR is there anything I can do to reduce time for putting .apk in android device?
You really should find out why adb transfers take so long. But if you insist on using serial console for uploads instead - you could just use any terminal application with XMODEM support on PC side to send the file and busybox rx -b <filename.apk> command on android side to save it. Then pm install <filename.apk> to install it.

AVD Emulator Browser won't use hosts file

I'm pretty frustrated with this one. I have a dev web server running a service feed for my Android app. I can browse to it from any number of machines.
On the AVD (and I've tried different versions all the same) I remount rw and pull, edit then push back the host file to system/etc/hosts. In the DDMS I see the date updated and if I pull it back off the changes are there.
Further if I go to a command prompt then run adb shell and ping the testhost name I get a reply from the correct ip. So why?????? will the avd browser not load the page. Oh yes the page. Plain HTML that says YES I am working.
In the end if I don't browse to the html page that's fine but since I need my app to query my service (hosted same site) for development and testing purposes I was thinking this would be a good test for connectivity before trying to have my app make a request to the service.
Stumped.
.....
Solved!!!
My windows background has me editing a hosts file with IP then tab then host name. Well I followed some instructions that had me edit the hosts from the adb shell. That worked...huh??? so I pulled the file and opened in Edit+ only to find I was shooting muyself in the foot. Only *ONE space between the ip and host name. It is working great now.
My windows background has me editing a hosts file with IP then tab then host name. Well I followed some instructions that had me edit the hosts from the adb shell. That worked...huh??? so I pulled the file and opened in Edit+ only to find I was shooting muyself in the foot. Only *ONE space between the ip and host name. It is working great now. If in doubt I would highly recommend updating your host file without pulling the file to the desktop. This is the command from the shell to do so.
./adb -s [DeviceID] shell
echo '###.###.###.### [HostName/URl]' >> /etc/hosts
exit
NOTE The above command is not every step needed just the command to actually edit the file from the shell. You still need to have write perms etc.
In windows host file its allowed to have multiple spaces (tabs) between IP address and hostname, but in android host file it requires single space between IP and HostName.
I tried with a host file with single entry in which IP and Hostname are separated by single space character using notepad++. But still problem persists, ie I was unable to open the site in emulator.
You can find steps to push host file of your local machine to android emulator ->
http://borkweb.com/story/setting-etchosts-on-an-android-emulator-using-a-mac
But still emulator is unable to use this host file which got resolved as ->
I tried this (Worked):
1. pushed a empty host file in emulator
2. Edited the same host file using adb shell echo command
#adb shell
#echo '172.30.1.227 fat.choice.plus' >> system/etc/hosts
#echo '\n172.30.1.227 static-fat.loyrewards.com' >> system/etc/hosts
use your IP address and hostname in above commands
To come out of adb shell use shortcut Ctrl + D
You can add multiple entries via echo using \n character for newline.
Emulator is now able to use this modified host file and site is loaded successfully. :-)
In my particular case, localhost subdomains give this problem on the android emulator browser (even though I can ping the domain), I was using the next mapping on my macOS 10.14:
10.0.2.2 something.localhost
Getting rid of the localhost fixed the issue for me. I don't know why this happens on my Mac, I couldn't reproduce this behavior on Ubuntu 18.04
The easiest way and the simple answer is:
It's the end of line(EOL) character for each line in the hosts file.
The EOL should be that of linux(LF).
The number of spaces or tabs doesn't matter.
For converting EOL character you can follow the following steps in notepad++:
Edit-> EOL Conversion-> Linux(LF).
To verify:
View -> Show symbol -> show end of line.
Once you have verified the above in your hosts file, simply push it to emulator.
Use the following commands to ensure your hosts file is replaced on emulator:
adb push ./hosts /etc/hosts
adb push ./hosts /system/etc/hosts
adb push ./hosts /etc/system/hosts
Note: You need to have your emulator running in write mode.

How to move apps to sdcard via shell script

I want to write a small tool to move apps to SDcard.
I found the movePackage()-method in Android Open Source and reflect the method. I failed because this method need com.android.PERMISSION.MOVE_PACKAGE which I cannot get. So I want to using shell script to do this for rooted devices.
But I don't actually know what happened in the movePackage()-method. So I can't write the correct script.
Could you please tell what happened inside the Android when a app is moved to SDcard? Can I do this with program?
I'm not sure If I understand you, but on rooted device you can use adb.
For example:
adb push /home/username/Desktop/app.apk /sdcard/app.apk
Also you can do this (for removing):
adb shell rm /sdcard/app.apk
If you want to install:
adb install /home/username/Desktop/app.apk

Categories

Resources