We are making our application system app by moving the apk to system dir and restarting the device. In order to do this, need to run couple of adb commands.
In the production stage we cannot ask the client to run all these commands from their system. So i wanted to know is there any was i can run an script file which will do all these processes for me.
Commands i need to execute:
adb root
adb remount
adb push /sdcard/download/base.apk /system/priv-app/
adb shell chmod 644 /system/priv-app/base.apk
adb reboot
And is it possible to run a script file without the help of any third-party application ?
Related
I am aware that using adb install command installs an app in the /data/app folder. Also I know the in order to install an app as a system app I need to push it directly to the system. Is it possible to use adb install directly to the /system/priv-app/ on rooted phones?
if I got your question, this should do the work:
adb root
adb remount
adb push apk-filename-here /system/app/
adb shell chmod 644 /system/app/apk-filename-here
adb reboot
See this or this link for more info.
You can not use adb to directly install app at /system/priv-app/. Even If you copy your .apk, .odex files to this path device can not recognize your app as system app. For this you have to use same certificate with which your system apps are signed.
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.
So I have a local Sqlite file I am trying to push to my Rooted Android (Nexus 7 2013) device. Which I have confirmed is Rooted by tying adb shell, su and seeing the # displayed instead of $
I am trying to run the following command:
adb push D:\tfs\MyApp\MyDatabase.db3 /data/data/MyApp/files/MyDatabase.db3
But I keep getting
Failed to copy ...MyApp.. to ...MyApp...: Permission denied
I have searched the internet and found answers here and here and have come up with the following:
adb shell su -c "mount -o rw,remount /data"
adb shell su -c "chmod 777 /data"
But even after running these two above commands and running my Push Command I am still getting Permission Denied.
What am I doing wrong?
'adb push' cannot push to data/data/ directory.
However, you can do it by using a transfer station like this:
adb push D:\tfs\MyApp\MyDatabase.db3 ~/sdcard/MyDatabase.db3
adb shell
su
mv /sdcard/MyDatabase.db3 /data/data/MyApp/files/MyDatabase.db3
It works for me,good luck to you.
To push an APK file Eg:"MyApp" to /data/local/tmp/ from my local C:/Apps
adb push C:/Apps/MyApp /data/local/tmp/ is giving Permission Denied error
Steps to make this work (issue these commands in an order)
adb shell
su
chmod 777 /data/local/tmp/
exit
chmod 777 /data/local/tmp/
exit
Now if i give adb push, it worked
adb push C:/Apps/MyApp /data/local/tmp/
Simple solution:
Instead of:
.\adb.exe push c:/files-to-push.zip /mnt/sdcard/Download
I used:
.\adb.exe push c:/files-to-push.zip /sdcard/Download
The problem I had
After going to adb folder(in my case c:/adb)
I connected with:
.\adb.exe connect 127.0.0.1:58526
And then I tried to push this zip file c:/Games/pokemon.zip by running:
.\adb.exe push c:/Games/pokemon.zip /mnt/sdcard/Download
I got this error:
adb: error: stat failed when trying to push to /mnt/sdcard/Download: Permission denied
Explaining my solution:
I was trying to push files to a path that does not exist...
In my case I tried to push to /mnt/sdcard/Download
Then after running adb shell I got access to console
Finally just typed ls to check which folder I had there
In my case I saw there was no /mnt
So after that I tried to ls /sdcard and saw Download folder there...
Ok so heres my solution.
My phone was already Rooted but for some reason this isnt enough to do anything you want.
I had to go and download the apk onto my device named adbd insecure mentioned here which you can download on that thread or from the google play store. I then had to open the App on my device and click "Enable Insecure adbd" and I also clicked "Enable at boot"
After this running my normal command:
adb push D:\tfs\MyApp\MyDatabase.db3 /data/data/MyApp/files/MyDatabase.db3
worked
Run the commands below:
adb root
or
adb wait-for-device root && adb remount
I have a simple problem.
I want to start/run a program file on an android phone using adb shell.
My Program is in /system/bin folder and has root privileges.
I want to run this program from my command prompt as adb shell runme 3000000 > logs.txt but it should not block the terminal, It should run in background.
I cannot use screen/disown/nohup for my problem as android doesn't have all this.
I tried
adb shell "runme >logs.txt &" but of no use.
When i issue command as
adb shell
# runme 3000000 > logs.txt &
It runs fine, when i exit the terminal/disconnect the device and then connect again to system.
Do adb shell ps | grep runme shows the process is still runnning in background.
Thanks
Busybox has nohup applet which works just fine in Android
I manually rooted my emulator using following commands
adb shell mount -o rw,remount -t yaffs2 /dev/block/mtdblock03 /system
adb push su /system/xbin/su
adb shell chmod 06755 /system
adb shell chmod 06755 /system/xbin/su
adb install superuser.apk
It is successfully rooted and working su command but while closing emulator and again opening emulator then su command is not working. To overcome this one I want to create a sample app for execute above commands programmaticaly using
Runtime.getRuntime().exec();
Please can one help me how to execute above commands programmatically.
The emulator is rooted out of the box in that the ADB shell runs as root.
What you've done is not "rooted" it, but rather used that pre-existing root shell to install a common hack which will then let application programs run helper tasks as root.
But you cannot do this from an application on the device which does not already have the ability to launch a helper as root - so you are stuck with a circular dependency or chicken-and-egg problem of needing root in order to install a root helper.
You will not be able to do this on the device or even emulator without finding a security hole (or pre-existing intentional privilege escalation mechanism) to exploit.
However:
you could read up on how to make the emulator's state persistent, and do it manually only once
you could issue the commands from a script running on the develpment machine, rather than on the device/emulator