Running app via ADB "** No activities found to run, monkey aborted." error - General Questions and Answers

I'm having issues with my Pixel being stuck in "pixel is starting..." with no luck retrieving my files or even opening apps.
I have been using
Code:
./adb shell pm list packages"
To get the list of packages and
Code:
./adb shell monkey -p "package name" -v 500
to try to run the package. The result is always an error. Are there any tips on what could be causing this error or how to resolve it?
Code:
.vzmsgs -v 500
bash arg: -p
bash arg: com.verizon.messaging.vzmsgs
bash arg: -v
bash arg: 500
args: [-p, com.verizon.messaging.vzmsgs, -v, 500]
arg: "-p"
arg: "com.verizon.messaging.vzmsgs"
arg: "-v"
arg: "500"
data="com.verizon.messaging.vzmsgs"
:Monkey: seed=1613020879167 count=500
:AllowPackage: com.verizon.messaging.vzmsgs
:IncludeCategory: android.intent.category.LAUNCHER
:IncludeCategory: android.intent.category.MONKEY
** No activities found to run, monkey aborted.

AFAIK the monkey tool is basically used to generate pseudo-random streams of user and system events, not to start apps. But I may err, as always ...
If you want to abuse monkey to start an app then the synthax would be
Code:
adb shell "monkey -p <package_name> -c android.intent.category.LAUNCHER 1"
where you replace <package_name> with the package name of the app you would like to launch.
BTW: Line
Code:
./adb shell pm list packages"
contains a synthax error. It should read as
Code:
./adb shell "pm list packages"

I have also tried
Code:
./adb shell am start com.verizon.messaging.vzmsgs
which results in
Code:
Error: Activity not started, unable to resolve Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=com.verizon.messaging.vzmsgs }

As I can see you didn't pass a valid activity.
Correct Synthax to start an app by AM is
Code:
adb shell "am start -a android.intent.action.<ACTIVITY>"
where you replace <ACTIVITY> with the activity expected by app to get launched.
Hint:
Always enquote the command line ( args ) you pass to shell ( aka Android's terminal )
FYI:
I no longer participate this thread: for me it just doesn't make sense anymore. May be others willing to help will join.

I am able to do this other commands like "pull" successfully with another android phone without any issue but not on the pixel. I cannot actually use the shell am start command successfully anywhere.

I was able to run on another device using:
Code:
./adb shell monkey -p com.verizon.messaging.vzmsgs -c android.intent.category.LAUNCHER 1
but on my pixel it fails

Related

adb pull problem

Hey,
This is probably more a linux question than an adb one.
Code:
$ adb shell ls /mnt/sdcard/DCIM/Camera/IMG_20100701* | xargs -n1 echo
/mnt/sdcard/DCIM/Camera/IMG_20100701_142914.jpg
/mnt/sdcard/DCIM/Camera/IMG_20100701_142959.jpg
/mnt/sdcard/DCIM/Camera/IMG_20100701_143015.jpg
/mnt/sdcard/DCIM/Camera/IMG_20100701_143125.jpg
/mnt/sdcard/DCIM/Camera/IMG_20100701_144112.jpg
/mnt/sdcard/DCIM/Camera/IMG_20100701_144814.jpg
$ adb shell ls /mnt/sdcard/DCIM/Camera/IMG_20100701* | xargs -n1 adb pull
' does not existmnt/sdcard/DCIM/Camera/IMG_20100701_142914.jpg
' does not existmnt/sdcard/DCIM/Camera/IMG_20100701_142959.jpg
' does not existmnt/sdcard/DCIM/Camera/IMG_20100701_143015.jpg
' does not existmnt/sdcard/DCIM/Camera/IMG_20100701_143125.jpg
' does not existmnt/sdcard/DCIM/Camera/IMG_20100701_144112.jpg
' does not existmnt/sdcard/DCIM/Camera/IMG_20100701_144814.jpg
The first one does what I expect it to do. Why does the second one give errors?
I am trying to write a script to sync my N1 photos when I plug it into my Ubuntu machine. I don't want to have to mount my sdcard. I'd like to do it over the adb,
Note that this actually works:
Code:
$ adb pull /mnt/sdcard/DCIM/Camera/IMG_20100701_144814.jpg
1740 KB/s (1129407 bytes in 0.633s)
When I specify the filename explicitly, it works. But when I get it from ls, it doesn't. Any idea why?
\R\N
The reason why adb doesn't work with xargs (from adb output) is because adb had \r\n line feeds.
This can be fixed by sedding those out:
adb shell ls /mnt/sdcard/DCIM/Camera/IMG_20100701* | sed -e "s/\r//g" |xargs -n1 adb pull

[GUIDE] SManager - How to use Commands

Hi,
I want to learn some of the commands for use in SManager (Script Manager) for ANDROID.
https://sites.google.com/site/devwom/script-manager
Does anyone know a suitable thread with guide or commands for SManager? I tried searching the web and XDA but did not find anything myself.
Specifically I want to know the cmd line to start an app.
EDIT 1:
Spent a good few hours trying to google a solution but drawn a blank.......Maybe Shell Scripts for Linux are not same as for Android...?
I would like to be able to run a script that does the following:
Checks if a directory exists on the sdcard
then executes a command (renaming of 2 directories)
then starts a program
EDIT 2:
well a few emails with the author of SManager and I was able to write my first script to check if the app is running and then if not, to rename folders and start the other version of the app. (I have Navigon Europe as well as Navigon Australia and was looking for a solution to allow both to co exist on my One-X at the same time. As both apps share the same directory structure the issue was that starting one version would overwrite the critical files of the other).
Now with my script installed as a widget I can toggle between each version without problem.
Here is some useful information on shell language for others (credits to the author of SManager Devwom):
http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
Here are some critical bits of info received during my emails with him:
Thanks a lot for your interest in SManager.
The requested commands is a mix between linux commands and android os commands.
To get info about each command you can search in google and select the preferred page.
But the commands available in each Android device depends on running rom.
To get all available commands in your device, simply execute a ls (lower case LS) in system directories, that is:
ls /system/bin
ls /system/sbin
ls /system/xbin
ls /system/usr/bin
ls /system/usr/sbin
ls /system/usr/xbin
These are the most common directories where binaries resides in android devices.
May be you also can have commands at:
ls /bin
ls /sbin
ls /usr/bin
ls /usr/sbin
usually android rooted roms have the well known busybox, to get a list all comands inside it simply execute
busybox
to get all installed packages (and running names) from your device you can execute:
pm list packages
to get info about running process
ps
or
ps aux
or
ps -aux
depending on ps version installed
If conditions are based on test bash command this command is a bit confused, because usually it is named as [, and other times it is built-in inside shell
read "test man page" to get a full list of test command flags.
To check if an app is running:
if [ -n "$(ps|grep os.tools.scriptmanager)" ] ; then
echo SManager is running
fi
To check if app is NOT running:
if [ -z "$(ps|grep os.tools.scriptmanager)" ] ; then
echo SManager is NOT running
fi
To check if a file exist:
if [ -e /sdcard/file ] ; then
echo /sdcard/file exists
fi
To check if a file exist and it is a directory:
if [ -d /sdcard/file ] ; then
echo /sdcard/file exists and is directory
fi
To rename a directory simply use mv command:
I hope you can build your script with this info.
Start app it is very easy but getting correct info to start app is a bit confused.
starting app uses "am command"
To get correct info to start app you should execute:
logcat |grep Starting
in a terminal on device
then go to launcher and launch desired app
then go back to the terminal and you will see a line with info about how to fill am command.
For example if you execute SManager
in
logcat|grep Starting
output you will see
I/ActivityManager(* 275): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=os.tools.scriptmanager/.launcherActivity } from pid 377
so to start scriptmanager you need the following command
am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n os.tools.scriptmanager/.launcherActivity
I do not know how to stop apps from command line, I usually use killall command:
killall os.tools.scriptmanager
if you do not have killall command you can use grep and awk or cut commands
kill "$(ps|grep os.tools.scriptmanager|grep -v grep|awk '{print $2;}')"
or
kill "$(ps|grep os.tools.scriptmanager|grep -v grep|cut -f5 -d" ")"
may you need adjust -f5 flag
To execute script as shortcut install SMWidgets.
Scripts usually ends with last line , ie, not special action is required, it will exit with the last executed command return code
Also you can add
exit 0
or preferred exit value, but 0 usually means OK
To end script in the middle use
exit value
where value usually it is not 0
Also it is better use mv command instead rename command.
rename command it is not linux standard, but mv command is in all linux shells.
Android shell programing it is not equals to linux shell programming but this was one of my first scripting documents many years ago and it can be used as a guide. http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
Best regards,
Devwom
Thanks, this is valuable information! It's a shame this thread didn't get more replies
I've been looking to change my wallpaper by script, but so far I haven't been succesful. With your guide, I guess I'm a step closer to my goals!
Hi.
Perhaps developer of smanager or any expert is reading...
I would like to write a script for 2 purposes. Both handle with samba share running on my ubuntu.
1st situation.: I would like to move my media, download and documents files from android to the desired folder on my Ubuntu, which is shared by samba in my LAN.
The goal is to start this script with just touching a widget.
2nd situation: I would like to copy files from my samba shared folder in ubuntu to a specific folder on sdcard in android. All files in folder on sdcard should be deleted before copying. Again just by touching a widget.
Shared folder on samba are with password and rw.
Till now I am doing it manually with esexplorer...
I would like to do it with script.
Sent from my Incredible S using xda app-developers app

[UBUNTU][DEBIAN]Common Commands used in Linux

Common Commands used in Linux.
Since, Android is based on Linux, there is much possibility that there is a need to use a Linux based OS. For such use, UBUNTU
is favoured, for its easy and more user friendly.
Today, I am going to Post a few commands that are very useful to the newbies to development
I myself am new, and have faced many problems with this, so I am posting a this thread, to help all the noobs/newbies find what they need in a single place
Okay so, lets start with some basic commands, which can be classified as general commands, and each Linux user MUST KNOW ALL OF THEM !!
Code:
sudo
It simply means "Superuser do". It requires password.
Code:
sudo apt-get install APPLICATION_name
This installs the application finding it on the internet, and gives you the suitable output(If the app exists or not).
Code:
sudo apt-get remove APPLICATION_name
It Removes the application
Code:
sudo apt-get update
it updates the repositories
Code:
sudo apt-get upgrade
upgrades your installed application with their latest versions from Ubuntu repositories
Code:
killall APPLICATION_NAME
kills (terminates) an application
Code:
ps -e
displays currently running processes
Code:
kill APPLICATION_PID
kills an application; where APPLICATION_PID.
NOTE: YOU CAN FIND "PID" USING EARLIER CODE.
Code:
wget http://path_to_file.com
downloads a file from the web to current directory
Code:
cd /PATH/TO/DIR
changes current directory to DIR. Use cd to change the current directory into any dir
Code:
cd ..
Like ms-dos, goes up one directory
Code:
dir
OR
Code:
ls
lists directory content
Code:
man COMMAND
Displays manual for command.
eg: man sudo
Code:
cp ORIGINALFILE NEWFILE
Copy a file
Code:
mv SOURCE DESTINATION
Moves a file
NOTE: YOU CAN ALSO RENAME A FILE WITH THIS.
EG: mv old_filename new_filename
Code:
mkdir FOLDERNAME
Make a directory/folder
Miscellaneous: Level 2
Code:
du -sh folder name
This calculates the size of the folder
Code:
ps -aux
This shows all the running processes
Code:
chown -R User:User dir
Change owner of files and directories
Code:
chmod 777 yourScript
This makes a shell script ".sh" extension
Code:
netstat -anltp | grep "LISTEN"
See all open ports on your machine
Code:
sudo apt-get install ufw
sudo ufw allow 80/tcp
sudo ufw allow 22/tcp
sudo ufw allow 443/tcp
sudo ufw allow 21/tcp
sudo ufw enable
Ubuntu provides a uncomplicated firewall (ufw). To install it and only allow SSH, FTP, and webtraffic use the following command.
Network Commands
Code:
ifconfig
Shows the network connections
WILL UPDATE REGULARLY AS MUCH I COULD.
Code:
passwd
Run after installing Linux when you see "[email protected]:~$" to set your root pass word
Code:
adduser
Replace and run to add a new user
Code:
adduser sudo
Replace and run to add that user to sudo
Code:
sudo apt-get purge
Replace and run to purge your system of that package
Code:
apt-cache search
Replace and run to search for new packages to install
Note: "wild cards" eg "*" are acceptable
Code:
find -type f -iname 'some-compressed-file*' -print0 | xargs -0 sudo tar -vxpzf
Replace with at least the "root" directory you want to search through and Replace " some-compressed-file " (leave the single quotes ' ' and the wild card *) and run to find every file under the given directory that has that name and the pipe " | " it out to tar so that'll extract to your current directory
Note: "find" does the finding, the "-type -f" tells find to only look for files, the "-iname" tells find to search parts of file names, the ' ' around "some-compressed-file" keeps the * from doing bad things, the "print0" tells find to "scrub" for spaces and such before outputting a result, the " | " pipes the results of find to xargs, the "-0" is because of "print0" in the find side of the pipe, and "sudo tar - vxpzf" is where tar extracts the findings of find.
Code:
find $HOME -type f -iname '*zip' -print0 | xargs -0 ls
Run to find and list every zip file under the home folder
Say you want to make a file to contain some notes wile in the command line
Code:
sudo cat > $HOME/someNotes.txt <<EOF
# place a command here
echo "hello world, I update aptget"
sudo apt-get update -q
EOF
Try editing the part after $HOME; type it in or write a file that contains the combo of " cat > $HOME/someNotes.txt <<EOF " some text or commands " EOF " and you'll find making custom scripts of varying complexity to be easy.
.......
Hope some of these are also found to be useful for others.
Thanks for starting this here thread.
Hit the link in my signature for more help with Linux for new and seasoned users
Edit 08082013- added another useful tip and reformatted commands to better fit the OP's formatting.
Sent from either my SPH-D700 or myTouch3Gs
Debian Kit/QEMU Linux Install guide for all android devices that I'm writing:
http://forum.xda-developers.com/showthread.php?t=2240397
Now have working Installers for ARM Java 7 JDK + Maptools + jMonkey
Yo ! Nice Share
To delete contents of a large text file ..
Code:
cat /dev/null > NameOfTheFile
Useful variations of ls command :
Show dir content in a list
Code:
ls -l
Show dir content in a list sorted by modification time (newer first)
Code:
ls -lt
Show dir content in a list sorted by modification time (older first)
Code:
ls -lrt
Show subdirectories recursively
Code:
ls -R
If you want to show files starting with . (hidden file), you can add -a option.
More options with command :
Code:
man ls
Useful variations of grep command :
grep is used to print lines matching a pattern.
Find the entry for current user in file /etc/passwd :
Code:
cat /etc/passwd | grep $USER
Find all the entry except current user entry in file /etc/passwd :
Code:
cat /etc/passwd | grep -v $USER
Find all the numbers in file /etc/passwd :
Code:
cat /etc/passwd|grep '[0-9]*'
Add color to grep command :
Code:
cat /etc/passwd | grep --color $USER
(You can add
Code:
alias grep='grep --color=auto'
in ~/.bashrc to always have colored grep)
Useful variations of tar command :
Create archive_name.tar from dirname :
Code:
tar cvf archive_name.tar dirname/
Create archive_name.tar.gz (compressed) from dirname :
Code:
tar zcvf archive_name.tar.gz dirname/
Extract archive_name.tar.gz :
Code:
tar zxvf archive_name.tar.gz
Useful variations of mkdir command :
Create directory and subdirectories if not existing :
Code:
mkdir -p /tmp/a/b/c
(mkdir /tmp/a/b/c will fail if /tmp/a and /tmp/a/b don't exist)
Useful tip :
Use bash variable "!$" to get the value of the last argument of the last command interpreted.
For example :
Code:
mkdir /tmp/test_a
cd !$ (equivalent cd /tmp/test_a)
or,
Code:
mv /tmp/a /tmp/b
ls !$ (equivalent ls /tmp/b)

[Q] how to launch an app from the terminal, opening specified file?

From the terminal, I would like to learn how to open a file in an android app.
As an example, how would I open /storage/emulated/0/Download/test.txt in Ted lightweight text editor?
When I try this:
Code:
am start -a android.intent.action.EDIT -n fr.xgouchet.texteditor/.TedActivity -d /storage/emulated/0/Download/test.txt
I get an error that includes "Permission Denial: startActivity asks to run as user -2 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL"
I'm not sure exactly what that's about, so I try to work around it with this:
Code:
am start --user 0 -a android.intent.action.EDIT -n fr.xgouchet.texteditor/.TedActivity -d /storage/emulated/0/Download/test.txt
Now Ted editor starts, but it opens a new file and not the specified file. I tried multiple times; one time there was a message at the top saying something to the effect that the specified file could not be opened. I've also tried different test files to exclude the possibility that test.txt is corrupt.
I'm stuck. Please help!
P.S. Ted's AndroidManifest.xml is available on github. I tried posting the link but, being new to the forum, I was not permitted to do so.
------------------
OS: CM11
Device: Moto G
Relevant apps: Terminal Emulator (jackpal.androidterm 1.0.65), Ted (fr.xgouchet.texteditor 1.8.1)
1) After countless hours of trial and error, I figured it out. Entering this command in the terminal opens the file for editing in Ted:
Code:
su -c "am start -a android.intent.action.EDIT -n fr.xgouchet.texteditor/.TedActivity -d file:/storage/emulated/0/Download/test.txt"
If you are reading this thread and like to write your own shell scripts, these two commands might also come handy if your script uses both CLI and GUI utilities:
2) To see the name of the app currently in the foreground:
Code:
su -c "dumpsys window windows" | grep mCurrentFocus | cut -d'/' -f1 | cut -d' ' -f5
3) To put the terminal in the foreground again:
Code:
su -c "am start -n jackpal.androidterm/.Term"
If you know how to do 1) (see my previous post) without root privileges, please post it here.
It doesn't make sense to me that root privileges would be required to open a user-owned file in a text editor. Android is linux, after all, so I'm hoping that anything a normal user can do via the GUI can also be done from the command line.

Cloning Pre-configured Android 8.1 Device / ROM

Hey guys,
Not sure if this is the correct place to post, but I am at my wits end and think I need a bit of help. I have been cloning devices on Android 7.1 without too much trouble, but something has changed in Android 8.1 which breaks things. Here is my setup:
Device: Xiaomi Redmi Note 4X 16GB, unlocked bootloader
OS: LineageOS 15.1 (Android 8.1)
My setup process is as follows:
Let stock ROM update (for latest firmware), unlock BL, flash TWRP, clean wipe, flash LineageOS + Gapps + Magisk
Skip through setup wizard, apply customisations (apps via APKs, launcher, settings, etc)
Clear Data for following:
com.google.android.gms.setup
Google App
Google Account Manager
Google Backup Transport
Google One Time Init
Google Partner Setup
Google Play Services
Google Play Services for Instant Apps
Google Play Store
Google Services framework
Reboot to TWRP
Connect to PC, run following ADB command: adb pull /data/system/users/0/settings_secure.xml
Open settings_secure.xml and delete "android_id" line
Push settings_secure.xml back to device: adb push settings_secure.xml /data/system/users/0/
Capture system image, flash onto other devices (either via TWRP backup or pushing system images via ADB)
Boot device, log into client Google account, done
Now this process used to work great on LineageOS 14.1 (Android 7.1), but now I get the following issues:
When adding a Google Account, it does not appear in Android device manager, but it appears in the list of devices in the Google Play Store? If I remove the account and then add it again it appears, but the issues below still occur.
Google's messaging / push system is broken. If I send a Hangouts message to my Google account, it won't appear until I open the app.
Any pre-installed apps won't appear in the "installed" list of apps in the play store, and therefore not update automatically until the user manually searches for the app in the Play Store and hits "update" (ugh).
I need to be deploying around 100 units over the next couple of months or so I need something that is scalable. I might be going around this the wrong way completely. I am not a ROM developer or programmer, just found something that has worked well in the past, so if I need to develop a ROM from scratch based on LineageOS I'll probably need to hire someone to do this for me as this is a bit beyond my current capabilities and time constraints. Let me know your thoughts! Thanks.
Android ID is same for many devices if you clone. That is really bad and can cause issues.
Rayman96 said:
Android ID is same for many devices if you clone. That is really bad and can cause issues.
Click to expand...
Click to collapse
I am deleting the Android ID from settings_secure.xml though. Unless it is somewhere else as well?
I'm still struggling with this problem. Is there anything else I can try? I googled this problem and the first result is this thread :/
stephendt0 said:
I'm still struggling with this problem. Is there anything else I can try? I googled this problem and the first result is this thread :/
Click to expand...
Click to collapse
Code:
adb shell settings delete secure android_id
adb shell settings delete secure advertising_id
adb shell settings delete secure bluetooth_address
adb shell settings put secure bluetooth_name 'YOURNAME'
adb shell settings put global device_name 'YOURNAME'
adb shell settings put global wifi_p2p_device_name 'YOURNAME'
The two IDs are then randomly regenerated. YOURNAME is any name of your choice.
rainman74 said:
Code:
adb shell settings delete secure android_id
adb shell settings delete secure advertising_id
adb shell settings delete secure bluetooth_address
adb shell settings put secure bluetooth_name 'YOURNAME'
adb shell settings put global device_name 'YOURNAME'
adb shell settings put global wifi_p2p_device_name 'YOURNAME'
The two IDs are then randomly regenerated. YOURNAME is any name of your choice.
Click to expand...
Click to collapse
Thanks for that. I believe I actually found their respective strings in settings_secure.xml:
<setting id="59" name="config_update_certificate"
<setting id="43" name="bluetooth_address"
And of course the Android ID. Once I deleted these, they auto-generated on the next boot, so I do this using ADB in TWRP.
I tried this and so far I'm not having any problems! Will report back if I experience any issues.
Another update - turn out that this is NOT enough. You will also want to clear data for the following apps (ideally just before shutting down the system and clearing android, bluetooth and config_update_certificate) to ensure that push notifications continue to work:
Com.google.android.gms.setup
Google App (not 100% sure if this is required, but I do it anyway)
Google Play Services
Google Play Store
Google Services framework
Reboot, clear your IDs, and then take your image. It should be OK after that, I think. I generally like to setup Hangouts on the device and then reboot, and let it sit for 5 minutes so its fully dozed before I send a test message.
Edit: STILL not working even after all this. Anyone else able to offer an explanation as to why push notifications is such an issue? This is becoming really difficult
stephendt0 said:
Another update - turn out that this is NOT enough. You will also want to clear data for the following apps (ideally just before shutting down the system and clearing android, bluetooth and config_update_certificate) to ensure that push notifications continue to work:
Com.google.android.gms.setup
Google App (not 100% sure if this is required, but I do it anyway)
Google Play Services
Google Play Store
Google Services framework
Reboot, clear your IDs, and then take your image. It should be OK after that, I think. I generally like to setup Hangouts on the device and then reboot, and let it sit for 5 minutes so its fully dozed before I send a test message.
Edit: STILL not working even after all this. Anyone else able to offer an explanation as to why push notifications is such an issue? This is becoming really difficult
Click to expand...
Click to collapse
ok, if you want to reset everything in a clone, proceed as follows:
Code:
adb shell su -c mount -o remount,rw /system
adb shell su -c rm /data/system/users/0/accounts.db
adb shell su -c rm /data/system/users/0/accounts.db-journal
adb shell su -c rm /data/system/users/0/photo.png
adb shell su -c rm /data/system/sync/accounts.xml
adb shell su -c rm /data/system/sync/pending.xml
adb shell su -c rm /data/system/sync/stats.bin
adb shell su -c rm /data/system/sync/status.bin
adb shell su -c pm clear com.android.packageinstaller
adb shell su -c pm clear com.android.providers.downloads
adb shell su -c pm clear com.android.vending
adb shell su -c pm clear com.google.android.backuptransport
adb shell su -c pm clear com.google.android.gms
adb shell su -c pm clear com.google.android.gsf
adb shell su -c mount -o remount,ro /system
Please also follow my instructions above for resetting the IDs before rebooting.
Google then recognizes a new device! Have fun :fingers-crossed:
rainman74 said:
ok, if you want to reset everything in a clone, proceed as follows:
Code:
adb shell su -c mount -o remount,rw /system
adb shell su -c rm /data/system/users/0/accounts.db
adb shell su -c rm /data/system/users/0/accounts.db-journal
adb shell su -c rm /data/system/users/0/photo.png
adb shell su -c rm /data/system/sync/accounts.xml
adb shell su -c rm /data/system/sync/pending.xml
adb shell su -c rm /data/system/sync/stats.bin
adb shell su -c rm /data/system/sync/status.bin
adb shell su -c pm clear com.android.packageinstaller
adb shell su -c pm clear com.android.providers.downloads
adb shell su -c pm clear com.android.vending
adb shell su -c pm clear com.google.android.backuptransport
adb shell su -c pm clear com.google.android.gms
adb shell su -c pm clear com.google.android.gsf
adb shell su -c mount -o remount,ro /system
Please also follow my instructions above for resetting the IDs before rebooting.
Google then recognizes a new device! Have fun :fingers-crossed:
Click to expand...
Click to collapse
OMG, I think that worked, thank you! I spent 5 hrs and stayed up to 3am trying to work this out with no luck, and this did the trick. To make things easier however, I morphed these commands into a dirty "one-liner" that saves entering each command.
Code:
adb shell settings delete secure android_id && adb shell settings delete secure advertising_id && adb shell settings delete secure bluetooth_address && adb shell settings put secure bluetooth_name 'Redmi Note 4' && adb shell settings put global device_name 'Redmi Note 4' && adb shell settings put global wifi_p2p_device_name 'Redmi Note 4' && adb shell su -c mount -o remount,rw /system && adb shell su -c rm /data/system/users/0/accounts.db && adb shell su -c rm /data/system/users/0/accounts.db-journal && adb shell su -c rm /data/system/users/0/photo.png && adb shell su -c rm /data/system/sync/accounts.xml && adb shell su -c rm /data/system/sync/pending.xml && adb shell su -c rm /data/system/sync/stats.bin && adb shell su -c rm /data/system/sync/status.bin && adb shell su -c pm clear com.android.packageinstaller && adb shell su -c pm clear com.android.providers.downloads && adb shell su -c pm clear com.android.vending && adb shell su -c pm clear com.google.android.backuptransport && adb shell su -c pm clear com.google.android.gms && adb shell su -c pm clear com.google.android.gsf && adb shell su -c mount -o remount,ro /system
I'm sure there is a more efficient way of stacking commands, but this worked. Replace "Redmi Note 4" with your actual device and reboot. I cleared data for any messaging apps and removed my Google account before I began, however.
stephendt0 said:
OMG, I think that worked, thank you! I spent 5 hrs and stayed up to 3am trying to work this out with no luck, and this did the trick. To make things easier however, I morphed these commands into a dirty "one-liner" that saves entering each command.
I'm sure there is a more efficient way of stacking commands, but this worked. Replace "Redmi Note 4" with your actual device and reboot. I cleared data for any messaging apps and removed my Google account before I began, however.
Click to expand...
Click to collapse
Perfect! You don't need to remove your Google account as the commands do this anyway
rainman74 said:
Perfect! You don't need to remove your Google account as the commands do this anyway
Click to expand...
Click to collapse
Quick update.
After a bit more testing, turns out that there were still a few things that needed clearing, particularly on different versions of Android (7.1). Also, I've noticed that a GSF ID can be generated before you get a chance to capture an image if you leave Wi-Fi enabled, so I've included that in the script. I've ended up with a .BAT file with the following:
Code:
echo on
adb shell settings delete secure android_id
adb shell settings delete secure advertising_id
adb shell settings delete secure bluetooth_address
adb shell su -c mount -o remount,rw /system
adb shell su -c svc wifi disable
adb shell su -c rm /data/system/users/0/accounts.db
adb shell su -c rm /data/system/users/0/accounts.db-journal
adb shell su -c rm /data/system/users/0/photo.png
adb shell su -c rm /data/system/users/0/settings_ssaid.xml
adb shell su -c rm /data/system/sync/accounts.xml
adb shell su -c rm /data/system/sync/pending.xml
adb shell su -c rm /data/system/sync/stats.bin
adb shell su -c rm /data/system/sync/status.bin
adb shell su -c pm clear com.google.android.ext.services
adb shell su -c pm clear com.google.android.ext.shared
adb shell su -c pm clear com.google.android.gsf.login
adb shell su -c pm clear com.google.android.onetimeinitializer
adb shell su -c pm clear com.android.packageinstaller
adb shell su -c pm clear com.android.providers.downloads
adb shell su -c pm clear com.android.vending
adb shell su -c pm clear com.google.android.backuptransport
adb shell su -c pm clear com.google.android.gms
adb shell su -c pm clear com.google.android.instantapps.supervisor
adb shell su -c pm clear com.google.android.gsf
adb shell su -c mount -o remount,ro /system
I have found that this works consistently across both LineageOS 14.1 and LineageOS 15.1 devices.
stephendt0 said:
OMG, I think that worked, thank you! I spent 5 hrs and stayed up to 3am trying to work this out with no luck, and this did the trick. To make things easier however, I morphed these commands into a dirty "one-liner" that saves entering each command.
Code:
adb shell settings delete secure android_id && adb shell settings delete secure advertising_id && adb shell settings delete secure bluetooth_address && adb shell settings put secure bluetooth_name 'Redmi Note 4' && adb shell settings put global device_name 'Redmi Note 4' && adb shell settings put global wifi_p2p_device_name 'Redmi Note 4' && adb shell su -c mount -o remount,rw /system && adb shell su -c rm /data/system/users/0/accounts.db && adb shell su -c rm /data/system/users/0/accounts.db-journal && adb shell su -c rm /data/system/users/0/photo.png && adb shell su -c rm /data/system/sync/accounts.xml && adb shell su -c rm /data/system/sync/pending.xml && adb shell su -c rm /data/system/sync/stats.bin && adb shell su -c rm /data/system/sync/status.bin && adb shell su -c pm clear com.android.packageinstaller && adb shell su -c pm clear com.android.providers.downloads && adb shell su -c pm clear com.android.vending && adb shell su -c pm clear com.google.android.backuptransport && adb shell su -c pm clear com.google.android.gms && adb shell su -c pm clear com.google.android.gsf && adb shell su -c mount -o remount,ro /system
I'm sure there is a more efficient way of stacking commands, but this worked. Replace "Redmi Note 4" with your actual device and reboot. I cleared data for any messaging apps and removed my Google account before I began, however.
Click to expand...
Click to collapse
YES, this did it. I cloned a kindle fire hdx using TWRP backup&restore and had to perform the action mentioned above in order to use both devices independetly.
ATTENTION!
Remember to change the values listed in stephendt0's example that were not part of the original code from rainman74:
- device_name: Equals the device type. E.g. adb shell settings put global device_name 'KFHDX'
- bluetooth_name: Hostname of the device seen in bluetooth.
- wifi_p2p_device_name: Hostname used for a p2p wifi network aka "ad hoc network". Not supported on all devices.

Categories

Resources