Using adb (Android Debug Bridge)

Connect your phone to your PC with a USB cable, enable USB debugging on your phone, and install and run adb on your PC. Then you can type commands on your PC and do low-level things to your phone or on your phone.

Installing adb:

+/- Doug Lynch's "How to Install ADB on Windows, macOS, and Linux"

  1. Install ADB on computer.
  2. Enable USB debugging on phone.
  3. Connect via USB cable.
  4. adb devices
    You should see just one device listed.
  5. If "adb -d devices" lists device as unauthorized, unplug USB cable, go to Settings / Developer options / Revoke all authorizations, plug USB cable in, should see "authorize this device ?", click OK, try "adb -d devices" again.

Adb also can connect via Wi-Fi or other TCP/IP, and can connect to an emulator instead of a real phone:
Android Developers' "Android Debug Bridge (adb)"

Using adb:


adb devices
adb -d devices

adb shell uname -a
adb shell ls -R /
adb shell cmd statusbar expand-settings
adb shell service call statusbar 1
adb shell top		# ctrl+C to exit
adb shell dumpsys -l
adb shell netstat -l -p
adb shell settings -h
adb shell settings list global >globalBackup.txt
adb shell			# "exit" to exit

adb bugreport >bugreport.txt

adb shell pm -h
adb shell pm list packages
adb shell pm list packages | grep google
adb shell pm list packages -f

adb shell pm uninstall PACKAGENAME
adb shell am start -a android.intent.action.DELETE -d package:PACKAGENAME

adb shell pm list permissions
adb shell pm list permissions -g -d
adb shell pm revoke PACKAGENAME android.permission.CAMERA

# Copy an APK from phone to PC:
adb shell pm path PACKAGENAME		# to get PATHNAME
adb pull PATHNAME
# Copy the NAME.apk file you got to NAME.jar, then open it.

adb logcat | grep "$(adb shell ps | grep PACKAGENAME | awk '{print $2}')"

# run adb and do logcat and color the output
# download and put it somewhere in your PATH, then:
ADB Shell
RMG's "30+ Most Used ADB & FastBoot Commands for Android 2019"
/u/perennialExhaustion's "Taking (almost) full control of your unrooted Android"

Unlocking Carrier

Some phones will be restricted to using only one telecomm company (carrier). To change that, you "jailbreak" (usually on Apple) or "unlock" or "SIM unlock" (usually on Android) the phone.

Wikipedia's "SIM lock"

Unlocking Bootloader


Normally, the user and apps will have restricted access to the filesystem, preventing changes to various system files and settings. To get full, super-user access to the filesystem, you have to "root" the phone (which mainly involves installing the Unix SU program and using it to set everything to run with super-user permission). But if you leave it running in that state, any malware application would have full access to all data and settings. And some applications will refuse to run on a rooted system, especially because it may allow you to subvert payment requirements or region restrictions (this may be called "failing SafetyNet" ?).

(SafetyNet: "... an online function from Google where Google checks with elevated privileges if your system isn't rooted, that no custom firmware is installed and the bootloader is locked. Some banking apps require this service to 'certify' your device too. ... Devices that fail this check cannot install some apps via the play store. But also some banking apps refuse to launch when the check is failed.")

Easy way to root the phone, but it installs lots of bloatware: Kingo Android Root

Whitson Gordon's "Everything You Need to Know About Rooting Your Android Phone"
Wikipedia's "Rooting (Android OS)"
Guiding Tech's "7 Tips to Secure Your Rooted Android Device"

After Rooting

Whitson Gordon's "Top 10 Reasons to Root Your Android Phone"
Brendan Hesse's "How to Customize Your Android Device With Magisk and Xposed Framework"
Nick Congleton's "How to Install Android Add-ons From Magisk Manager"

Robert Zak's "How to Install Apps on Android without Google Play Store"
MakeTechEasier's "9 of the Best Android Apps Not on the Google Play Store"

Android Custom ROMs


  • One big reason to install a custom ROM is to get a newer version of Android than your phone manufacturer supports. This gives you new features, maybe new apps, more bug and security fixes, maybe more memory space because newer versions use SD card better.

  • Another reason is to avoid using Google play store, apps, and services.

    Removing Google services will break some apps you might want. You could try using microG to replace Google services.

    You could try using Aurora Store or Plexus to see which apps you use today depend on Google services. Some popular apps (WhatsApp, Facebook, Telegram, Twitter, Instagram, LinkedIn, Spotify) don't use Google Services. article

  • If you just want to tweak settings or remove standard applications, you could just root the phone instead of installing a custom ROM.

  • Each custom ROM project supports a limited number of phone types. I'm tempted to pick a ROM and then go buy one of the phones it supports.

Choosing ROM


Before Installing

  • Before installing any custom ROM, check that it supports your model of phone, and look for user reviews or experiences.

  • Decide what you're going to do about Google services: install them, do without them, or replace them with microG. article

  • Decide what you're going to do about Google apps: install them, or replace them with other apps.

  • Before installing a custom ROM, you'll have to root your phone, unlock the boot-loader, and install a custom "recovery". Popular "recoveries" are TWRP (Team Win Recovery Project) and CWM (ClockworkMod Recovery). But check the instructions for the custom ROM you've chosen; some may not require rooting.
    XDA's "How to Install TWRP"
    Android Tips and Hacks' "TWRP: the complete guide to using Recovery on Android"

  • Apparently it makes no difference whether or not your phone is encrypted; it's never mentioned in the instructions.

  • I'm not sure how much free memory space your phone must have. I think if you do "sideloading", new ZIP files (about 1 GB) are downloaded to your computer instead of your phone, so much less phone memory needed.

  • Risks of the process:
    • You might wipe data, and then find that your backup was bad or recovery doesn't work.

    • You will void the warranty (if any) on your phone.

    • You might "soft brick" your phone (make it unable to boot all the way), which means you'd have to fix it.
      Philipp Greitsch's "How To Fix Your Soft-Bricked Android Device - First Aid Guide"

    • You might "hard brick" your phone (make it unable to boot at all), which means you'd have to throw away the phone. But from /u/noahajac: "it is extremely difficult to hard brick a phone these days without the intention to do so".

    • You'll probably end up with the phone rooted, which means any malicious app can access all of the data. And may make you fail SafetyNet, which means some apps won't run.

    • You'll probably end up with an unlocked boot-loader, which has dangers (what ?). And may make you fail SafetyNet, which means some apps won't run.

    • You'll have to do any later minor system updates yourself; they won't happen automatically through Android's built-in software update facility ? But I think Lineage OS has an app to do this for their ROM.

    • You will have to trust that the supplier of the custom ROM has not put any malware in it. Get the files from XDA or the ROM builder directly, not any of the aggregation/downloading sites.

    Madaidan's Insecurities' "Android"

Getting Software

  • To go with your custom ROM, you'll need a matching GApps package for it.

  • Download recovery, ROM, and GApps files (ZIP files) to your computer. Don't unzip them.


  • These articles cover all the steps, with some more complete than others:
    WikiHow's "How to Install a Custom ROM on Android"
    Whitson Gordon's "How to Flash a ROM to Your Android Phone"
    XDA's "How To Install Custom ROM on Android"
    Andy Betts' "How to Install a Custom ROM on Your Android Device"

    The steps (unless instructions with the custom ROM say otherwise) are:
    1. Install Android Debug Bridge and phone's drivers on your computer.
    2. Enable USB Debugging on the phone.
    3. Connect USB cable between phone and computer.
    4. Root your phone.
    5. Make an apps-and-data backup, using Titanium Backup.
      XDA's "How to Backup Android"
      Whitson Gordon's "How to Back Up and Restore Your Android Phone with TWRP"
      random neuron misfires' "HOWTO: Back up your Android device with native rsync"
    6. Unlock boot-loader.
      Whitson Gordon's "How to Unlock Your Android Phone's Bootloader, the Official Way"
    7. Install new recovery.
    8. Make a full "nandroid" backup, which includes the ROM and all data, using TWRP.
    9. Install new ROM.
    10. Install new GApps.
    11. Restore applications and data.

    From /u/noahajac on reddit's /r/LineageOS 5/2017:
    > install Lineage OS on Samsung Galaxy S4 GT-I9505:

    The following instructions are for Windows only. Please don't use a virtual machine as these can cause problems communicating with the device. ...

    First we need to download the tool that flashes to the devices different partitions. On most devices you use a tool called fastboot, but Samsung devices aren't like most devices. This tool is called Odin, it's Windows only and leaked from Samsung so you need to get it from a trusted source. You can download the latest version (as of 5/5/2017) Odin. Extract the "" file. You should now have a folder called "Odin_3.12.3". Treat this as your working directory and download all other files to this folder.

    You don't need a PIT file for your phone.

    GT-i9505 is same as "Qualcomm" version of phone.

    Now we need to download Team Win Recovery Project, or TWRP as most people call it. TWRP is a custom recovery. A recovery is a mini-OS that is stored on another partition of the device that can do basic functions like flashing and wiping. TWRP is one of the more full featured recoveries as it has stuff like backup and restore built in. Devices do have stock recoveries but these are programmed to only flash files signed by the vendor, people don't often notice this but stock recovery is what the device uses when you run an OTA (Over The Air) update or a factory reset. You can get the latest version (as of 5/5/2017) of TWRP for your device TWRP. Make sure to click "Download twrp-3.1.0-0-jfltexx.img.tar" to download the actual file.

    Now we need to download the Android platform tools. These contain multiple tools (including fastboot as I mentioned earlier) but we are after ADB (Android Debug Bridge). It has multiple use cases and can be used in recovery or just in the normal Android system. You can download the latest version (as of 5/5/2017) of the platform tools for Windows tools. Extract the "" file and there should be a "platform-tools" folder. Open this folder and move its contents into the "Odin_3.12.3" folder from before.

    Now to download LineageOS itself. Custom ROMs, along with a bunch of other things come in a flashable zip format that gets flashed using a custom recovery. LineageOS has two build types as of now, one is an experimental migration build, and the other is the normal build. As you're doing a clean install you need the normal build. Please keep in mind stability isn't promised and it is recommended to keep TWRP backups. You can get the latest build (as of 5/5/2017) for your device [broken link].

    The next file we need is Gapps (well we don't actually need it but the majority use it). Gapps (Google Apps) are basically all the Google branded apps like the Play Store and it's needed services. They come in multiple variants depending on how many Google Apps you want. I usually recommend either the stock package (installs Google Apps like it's on a Nexus) or the nano package which is smaller and installs just the needed apps. You can get the latest nano package for your device: nano. Or the latest stock package: stock.

    Also, if you would like to have root access you will need to download the optional root add-on from [broken link]. Keep in mind if you want SafetyNet to pass you would need to use an unofficial root method like Magisk.

    Now to prepare the device to be flashed. Go into settings and look for "Developer Options" or something along those lines. If it isn't there, go into "About phone" and tap "Build number" 7 times. Then go back up into settings. They should be there now. Enable "Developer Options" (if it has a toggle) then enable "USB Debugging". This allows us to use ADB on the stock ROM but it usually isn't needed (we enable it just in case). Also enable "OEM Unlock" if it's there, this would allow us to flash unsigned images to the device however not all builds have this setting so you may not need to enable it. Also go back into security settings and disable "Reactivation Lock" if you can, because sometimes it can cause issues. Once you have these options set, say goodbye to your stock ROM and just pull your battery.

    Reinsert the battery and then hold the Volume Down, Home, and Power keys. This should put the device into download mode; hold the keys until you see that. Accept any warnings then plug the device in. Open "Odin.exe" from the "Odin_3.12.3" folder. In the log, it should say Added! and have a blue COM thing near the top, meaning it detected your device. If it didn't detect it, then tell me because that means you probably have a driver issue. Click the "Option" tab and make sure "F. Reset Time" and "Auto Reboot" is enabled. Also check the checkbox next to the "AP" button and then click the button. Select the "twrp-3.1.0-0-jfltexx.img.tar" file. Now on the device, hold the Volume Up and Home keys and click "Start" in Odin. Normally the key combo to get into recovery is Volume Up, Home, and Power but since Odin is going to auto reboot the device when it finishes flashing we don't need to use the Power button. If it's too hard to click "Start" at the same time as holding the buttons. You can just disable "Auto Reboot" and click "Start". Once Odin says "RESET" or "PASS" near the top and says it successfully flashed in the log. You can then just hold the Volume Up, Home, and Power keys. Whatever method you choose, keep holding the keys until you see the Team Win Recovery Project (TWRP) splash screen.

    It's going to ask you if you want to modify the system, you can just allow it to do this by swiping the slider. It may also ask you anytime during the process if you want to root, don't let it do this. Now click "Wipe", "Advanced Wipe", select "System", "Data", and "Cache", and then swipe the slider. This clears the partition that user data is stored in, along with the caches. Once that finishes you can click the home button. Now click "Advanced" and click "ADB Sideload". Swipe the slider, you don't need to wait for it to start as it will start once it gets the command from your computer. Open a command prompt Window up to the "Odin_3.12.3" folder and run "adb devices". After the message about starting the daemon you should see something like "SERIALNUMBER sideload". If you don't then tell me because that means there is probably a driver issue. There is multiple methods to flash with TWRP but this is my favorite as it doesn't leave the files on the device. Now just run "adb sideload" to flash it. The percentage is inaccurate so don't worry if it goes over 100%. TWRP will say once it finishes. Don't reboot yet though, we still need to flash Gapps. Click the home button and go back to the ADB Sideload menu. Swipe the slider and this time run the same command but for the Gapps file ("adb sideload" in my case). If you want root, do the same step for the root add-on ("adb sideload" in my case) once Gapps is done flashing.

    Now you can "Reboot System" to reboot into LineageOS. You should now see the LineageOS boot animation. The first boot may take up to 15 minutes but you should soon be seeing the setup wizard where you can continue like you normally would. If it doesn't boot, tell me.

    If you flashed the root add-on don't forget to enable it in developer settings.

  • I have a Windows 10 computer with USB cable to phone.

  • I have a Samsung Galaxy S4 GT-I9505 phone with 16 GB memory running Android 5.0.1.

  • Lineage OS has a custom ROM and GApps official-lineageos-14-1 for Android 7.1 (Nougat) for my phone. It's marked official, weekly, experimental, and nightly ?

  • I want to get a sense of how stable it is. Changelogs on the nightly downloads are empty. Went to reddit's /r/LineageOS. I don't see any error reports, and my phone is pretty basic and old, so I think I'm okay.

  • What I did:
    1. Installed Titanium Backup and TWRP Manager apps on my phone. The apps both want root mode, which I don't have yet.
    2. Turned on USB Debugging Mode. I don't see "OEM Unlock" or "Reactivation Lock" settings.
    3. Installed Android SDK Tools on my computer from instructions in Whitson Gordon's "How to Unlock Your Android Phone's Bootloader, the Official Way" failed. There's no "SDK Manager.exe" to run.
    4. Installed ADB and fastboot from instructions in Eric Ravenscraft's "The Easiest Way to Install Android's ADB and Fastboot Tools on Any OS" worked.
    5. Tested ADB by opening a command window in the new folder and running "adb devices". Got a code and "unauthorized" in the list, and a "let this device connect" dialog opened on my phone. Said yes, did "adb devices" again, got a code and "device" in the list. Working.
    6. Downloaded Heimdall Suite from heimdall-suite-1.4.0-win32 and extracted it.
    7. Downloaded zadig.exe from and put it in "Heimdall Suite / Drivers" folder, overwriting the older version already there. Plugged in phone, logged in to phone, ran zadig.exe, followed instructions in Heimdall README file, and got "driver installation failed - resource already installed".
    8. Downloaded PIT file from xda-developers and put extracted file in "Heimdall Suite" folder. There seem to be a lot of scam sites offering PIT files; be careful. Ran "hiemdall-frontend.exe", went to Utilities, loaded the PIT file. It loaded okay, but I don't understand the contents.
      Found another PIT file at xda-developers. On casual inspection, it seems identical to the other one.
    9. Downloaded Lineage OS 14.1 file from [broken link] and put zip file in "Heimdall Suite" folder.
    10. Downloaded GApps arm-7.1-full file from gapps and put zip file in "Heimdall Suite" folder.
    11. Downloaded rooting file su(arm) from extras and put zip file in "Heimdall Suite" folder.
    12. Tried to root phone by downloading Kingo Android Root from Kingo Android Root. Installed it on computer (installer tried to install bloatware and change my home page, be careful). Ran it with phone connected and well charged, and it ran for 5-10 minutes, up to 99% progress, saying all this stuff about rooting. Then at 99% it said "okay, last step is to flash a custom recovery, okay ?". I said cancel, and it said "rooting failed". Restarted the phone, everything is fine, but phone is not rooted. But Kingo installed a couple of bloatware apps I didn't want: SuperBattery and AliExpress.
      Then I saw this in their FAQ:
      "There are two universal ways to root your Android, one is by implementing "exploits", the other is through flashing custom recovery. The former one is relatively safe while the latter one can be risky. Kingo mainly focused on "exploits" method, but also covers "recovery" for certain tricky devices (hot ones with no exploit available)."
      So I ran it again, it took 10-15 minutes, then I allowed it to flash a custom recovery. It restarted the phone a couple of times, phone said it was restoring the stock recovery, then I had to log in to phone a couple of times, then Kingo said rooting succeeded, then phone said updating apps and updating Android. Finally done, phone still works, Titanium Backup says it has root permission.
    13. Ran Titanium Backup app to do backup. Very confusing; couldn't figure out how to back up just an app's data, without also backing up the app itself. And I'm not sure where the data is being backed up. In the cloud ?
    14. Tried to do backup by direct filesystem access through USB cable. Mainly, I wanted to back up my Contacts. But I couldn't find the file where they're stored.
    15. Now /u/noahajac tells me Kingo is essentially spyware, I probably shouldn't have used it. But it was a quick way to root and be able to use Titanium Backup.
    16. Followed /u/noahajac's instructions to use Odin to flash TWRP, and it seemed to succeed, but my phone won't boot into TWRP. Says something like "Recovery not SEANDROID enforcing" and gives black screen. Can still boot into normal ROM; nothing changed there. Searching, I see this error is a mismatch between versions of TWRP and ROM. But that's the whole point, I'm upgrading.
    17. Found an answer and it worked: after seeing "Recovery not SEANDROID enforcing", let go of Home and Power buttons, keep holding Volume+ button, and TWRP will boot eventually.
    18. In TWRP, tried to wipe data, got all kinds of "can't find /data" and "can't find partition" failures. Maybe because my phone is encrypted ?
    19. Then I realized I should have done a TWRP backup first. Too late now.
    20. Yes, wiping is different because my phone is encrypted. Did "Wipe --> Format Data" first, then wipe data, all worked.
    21. Did "adb sideload" which succeeded.
    22. Did "adb sideload" which failed because not enough space.
    23. Did "adb sideload" which succeeded.
    24. Did "adb sideload" which succeeded.
    25. In TWRP, clicked "Reboot System". Got "no OS installed" warning, ignored it. Kept going, phone rebooted, got something on phone about "not SEANDROID enforcing", then into a small green arc animation which I think is LineageOS starting up. Took about 5 minutes. Then it started going through phone setup stuff: select language, connect to Wi-Fi, etc. Got through it, tweaked various settings, it's working ! Powered off, powered on, looks good !
    26. Clicked LineageOS build number seven times to get into developer mode, then turned on root access for apps.
    27. Phone started the process encrypted, ended up unencrypted.
    28. Installed Titanium Backup, and the backups I did are nowhere to be found [told later: the backup was done to internal memory, which then got wiped]. Have to rebuild my Contacts etc from scratch. There wasn't much on the phone, so it's not hard. [Also realized later: I should have done a backup inside the WhatsApp application before starting.]
    29. I've heard stories of phones getting bricked when people apply ROM upgrades. So I'm not going to do that. And should do a TWRP backup before trying any upgrade. Also might brick if you try to flash a new TWRP.
    30. Still have to do this trick to boot into TWRP: after seeing "Recovery not SEANDROID enforcing", let go of Home and Power buttons, keep holding Volume+ button, and TWRP will boot eventually.
    31. Did a TWRP backup. It gave an error "E: failed to write /dev/block/mmcblk0p9: I/O error" before starting the actual backup, but otherwise seemed to work. Warns the backups of Data do not include files such as pictures or downloads. Took about 2.2 GB of storage ! Took about 3 minutes. The storage used is in type "Other" in Settings/Storage.
    32. So far, I don't see any amazing new features in Android 7 as opposed to 5. You can revoke permissions from apps. If I had an SD card, I guess I could use it for app storage.
    33. Biggest problem: something is draining the battery heavily. But changing Location setting from "High accuracy" to "Battery saving" seems to have fixed most of that.
    34. 5/2018: phone died, won't charge or run off charger. New battery revived it for a moment, then it was dead again. Took it to a shop for repair, and they replaced the entire internals of it. I had little data in it, so that's no problem, but goodbye LineageOS, it's running empty stock Samsung Android 5.0.1.
    35. 8/2018: for 2 months I've been using a phone running empty stock Doogee Android 6.0, and I really don't miss LineageOS.

From /u/trondwin on reddit's /r/LineageOS 8/2018:
Painful Lineage OS installation:

I bought a used LG G3 d855 to install Lineage OS on and use as my (only) phone. The installation instructions (at for the phone seemed (reasonably) straightforward, even for a novice user like myself, so I thought this would be a fun, little project. However I ended up using 20-30 hours (over multiple weeks) in total.

This is not meant as a complaint - on the contrary, I am full of gratitude to all developers creating open source software - You're making the world a better place. Rather, by describing the efforts I went through, I hope others may learn something from them and get an easier time than I had.

Here are the main painpoints and time sinks I encountered.
  • Unable to root from Linux. I thought that this would be a no-brainer (hey, Linux has everything!), but no - it seems you have to have access to a windows pc to root the phone. Lesson: Use a windows pc to root.

  • The main time sink was trying to root the phone (from Windows). Eventually I downgraded the phone to Android 4.4 (KitKat) to root it, and then the root instructions from linked from the lineage os wiki were more or less ok. However, before I got there I went via multiple failed attempts to root from Android Lollipop and Android Marshmallow and a bootlooped phone before the ultimate success. Lesson: Find and install an appropriate version of Android before rooting.

  • Installing custom recovery (TWRP). The instructions at the lineage wiki said to push the recovery file to /sdcard, but that is not the correct location for Android KitKat on LG. Quite a few hours trying, researching, trying again. In the end, the place to push was /storage/external_SD/, but I believe this may be LG/KitKat specific. Lesson: Not sure.

  • It also took me a little bit of time to realise I had to install an actual SD card in the phone to install the TWRP - I've read this before, but the instructions for the phone at the lineage os wiki said nothing on this. (You may write this down as "beginner" if you want to, and you will not be entirely incorrect.) Lesson: Install an SD card :)

  • Installing LineageOS from recovery. I got an error 7, because the installation expected a different Android version than the one I was using. Removing the version checking from the installation script fixed the issue. Lesson: Search for specific error messages you get.

Ultimately, the instructions at the lineage os wiki were not particularly helpful. Specifically, they're somewhat misleading in that they make no provision at all for differences in Android versions. I found no other web site with a complete AND working tutorial, either - I had to research each specific problem as it occurred.

The good news - it DID work out in the end. It was actually doable, and I believe it will be for other phones and android versions as well.

I'd like to end with a thank you to all developers using their time to develop free and open source software. Thank you!


From people on reddit's /r/LineageOS 5/2017:
Updating to the latest TWRP build should solve updating issue. You don't have to flash Gapps each time you update, but Magisk, you might have to.


You need to update to the last version of TWRP 3.1.1-0 for automatic updates to work properly.

You don't need to reinstall Gapps each time. There is a script in the addon.d folder that backs it up and restores it after you have finished flashing.

The Play Store will keep your apps up to date.

You can use a script. I've been using it for a bit now and it's pretty handy and fairly simple to set up:

Download the script from xda-developers [DEAD LINK]. Get rid of the .txt extension, then move it into your addon.d folder (located at /system/addon.d).

Create a folder called 'FlashAfterUpdate' in /sdcard (your internal storage). Any .zip placed into that folder will be flashed after an update. I have my in there.
From someone on reddit's /r/LineageOS 6/2017:
Back up your device through TWRP before an update, and archive these backups somewhere (cloud storage, etc) in case an update screws with your phone. TWRP does not preserve your data partition, so you will have to redownload music, etc. App settings should get preserved, but correct me if I'm wrong.

If you're having issues after updating LineageOS, try wiping the cache and dalvik cache.

From someone on reddit's /r/LineageOS 11/2017:
Here's how I update mine:
  1. Check for an update and download it.
  2. Reboot to recovery.
  3. Flash update and Magisk.
  4. Clear cache and reboot.

How to flash new TWRP ?
From someone on reddit's /r/LineageOS 5/2017:
Open TWRP app with root permission. Press TWRP Flash, Select Device and download the .img file. Now come back in the TWRP app, press select a file to flash ... Usually in sdcard/Download/.img and boom.
In "Select Device", my phone is "Samsung Galaxy S4 International Qualcomm", files have "jfltexx" in the name. Select the ".img" file. After it downloads, click "Flash to Recovery". Takes only a few seconds. Then out of app, reboot phone into Recovery, check TWRP version.

How to do an LOS update ?
Go into Settings / About Phone / LineageOS Update.
Select a new version and click "Download" button.
After it finishes downloading, see "Apply Update ?" dialog, click "Apply".
Boots into TWRP.
Click on "Install" button.
Find downloaded version in /data/data/org.lineageos.updater/app_updates and install it. Do NOT check ZIP signature; it will fail.

Encrypting the phone: Update to latest TWRP first (there was some bug). And do a full backup.

Backing up

Power phone down using power button.
Boot into TWRP by clicking power button and then holding Vol+ button until TWRP logo appears.
Click Backup.
Partitions selected: Boot, System, Data (excl storage).
Swipe to backup.
See progress.
When done, click Reboot System.
Boot into LineageOS.
Connect USB cable to computer and select Transfer files.
In Windows Explorer, go to [phone] / TWRP / BACKUPS / [code] and you will see a dated backup folder.
Move backup from phone to computer, including [code] folder. Don't copy it, move it, to make space for next time.


Application components:

  • Activities: screens/pages. Some IDEs offer pre-built Activities including Bottom Navigation Activity, Google Map Activity, Login Activity, Settings Activity, Tabbed Activity, more.

  • Services: do background processing.

  • Broadcast Receivers: handle messages (intents) from OS and other applications.

  • Content Providers: handle data and database management. (SQLite is built into Android, accessed through "android.database.sqlite" and SQL statements. There also are files, stored in internal or external storage.) An app can expose content providers for other apps to use, or keep them private. Examples: to get all contacts "content://contacts/people", to get a specific contact "content://contacts/people/2", to get your app's specific data maybe "content://com.MYAPPNAME.MYINTENTNAME/MYTYPENAME/3".
Application manifest file AndroidManifest.xml lists these and specifies how they interact. Also specifies things such as themes to apply to whole app or to specific Activities.

  • Fragments: behaviors or pieces of UI, which can be placed in Activities. Standard fragments might include Google Map, more.

  • Views: UI elements. Standard views include TextView, EditText, Button, CheckBox, RadioButton, ProgressBar, DatePicker, more. Views can receive and handle Events such as Click, LongClick, Key, more. Adapters connect Views to data sources.

  • Layouts: hierarchies of views (using viewgroups, widgets, views). Standard layouts include Linear, Relative, Table, Absolute, Frame, List, Grid.

  • Intents: messages among components or among apps. Requests (e.g. someone make a phone call to N, someone do a web search of X, send email, send SMS) or events (e.g. battery is low, or Call button was pressed). They can be system-wide (AKA "implicit": addressed as "android.intent.action.*") or app-specific (AKA "explicit": addressed as "com.MYAPPNAME.MYINTENTNAME").

  • Resources: strings, images, styles, etc.

The app can send Notifications, which can contain links back to Activities in the app.

The app can use OS / Google Play services such as Location, Alert Dialog, MediaRecorder, AudioManager, Bluetooth, Camera, Clipboard, Maps, more.

Standard base language is Java, but you also could use C++ or Kotlin.

"No-code" app development ?
Glide (build from a Google Sheet)
Andromo ($8/month)
AppsGeyser (ads)

NoviceDock's "Android Development Syllabus"
Romansh Yadav's "Understanding Android OS Architecture"
Tutorials Point's "Android - Architecture"
Do mockup with Balsamiq or Lucidchart or something similar.
Sayak Boral's "The Beginner's Guide to Android Studio"
Tracey Rosenberger's "How to Set Up and Run Android 9 for Development on Your Computer"

"Android Emulators" section of my "VMs and Containers" page
"Flutter / Dart" section of my "Develop an Application" page

# install Android studio
# download, unpack, move to ~/android-studio
cd ~/android-studio/bin
# This creates ~/Android
# config is in ~/.config/Google/AndroidStudio4.1

# In Android Studio, click "Configure", then
# "SDK Manager", then tab "SDK Tools", then
# enable "Command-line Tools".

# Edit ~/.profile to add:
export JAVA_HOME="$HOME/android-studio/jre"
export PATH="$PATH:$JAVA_HOME/bin"

# log out and back in

# create shortcut to $HOME/android-studio/bin/

# launch Studio
# Create new Flutter project
# Name must be of form something_something_something
# Flutter SDK path /home/user1/flutter
# create project

# open project
# select Run / Run
# edit configurations

See: Flutter


Not enough memory to install app


  • Google Play Store.

  • F-Droid

    And under Settings / Repositories you can enable additional repos. I don't know if this is a good idea.

  • Aurora Droid (pulls from same store as F-Droid)

  • What is the Kali NetHunter App Store?

  • Aurora app store (a client for Google Play apps without using the Google Play Store app)

    From people on reddit 3/2020:
    Has useful filters when searching for apps (minimum rating, ads, IAPs, minimum downloads); if you don't want to update an app for any reason you can blacklist it; you can download apps from other countries.
    But: downloads sometimes randomly bug and don't complete; need to re-login with Google account all the time; sometimes search an app and it just doesn't show up at all; to update all apps, you need to manually tap "allow" each time an update downloads, for each app; it says using Google account in Aurora Store will lead to ban by Google, so use Anonymous.

    Home page seems to be AuroraOSS app.

  • APKMirror (especially for beta-test versions of apps)

  • APKPure

  • Yalp Store.

  • Aptoide.

  • Amazon Appstore.

  • Mobogenie.

It seems any particular app X tends to be in either Google Play Store or in F-Droid, but not in both ?

Some differences among the stores:
  • Requirements for admission: e.g. F-Droid allows only open-source, Google Play Store doesn't allow ad-blockers ?

  • Because of the open-source requirement, some apps have different features/subsystems in the different stores (e.g. Firebase subsystem).

  • Some apps have different pricing in the different stores.

  • Degree of screening of apps; e.g. Google has "Play Protect".

  • Because of market share, some apps may publish first to Google Play Store, then later to other stores.

If you've installed a custom ROM and want to avoid Google Play Store but install apps from the Store: first install F-Droid, then through F-Droid install Aurora Store, then through Aurora Store install apps. YOu can use Aurora Store with anonymous login (not using your Google login), and keep your phone logged out of Google ?

Be careful:

+/- Watch out for named-alike apps: malicious app given same or similar name as some legitimate very popular app. Check the "made by" company name.

Watch out for fleeceware apps: subscriptions that say $10/year in big print and then $10/week next to the button where you're paying.

Apps I like to add:

+/- Be careful; there are lots of named-alike apps that may be malicious, or just trying to profit off another app's success. Check the name and vendor name carefully.

"Productivity" apps:
  • A bank app.
  • Firefox.
  • Flashlight Free: No Permissions by Humberto.
  • IRS2Go (for US IRS).
  • K-9 Mail by K-9 Dog Walkers, and OpenKeychain: Easy PGP by Cotech.
    Join the K-9 test program.
  • DAVx5 by bitfire web engineering (from F-Droid), to connect to server for calendar and contacts.
  • aCalendar by Tapir Apps GmbH.
  • Keepass2Android Offline.
  • Lightning browser by Anthony Restaino (from F-Droid).
  • Malwarebytes Security ... by Malwarebytes.
  • Music Folder Player Free by Zorillasoft.
  • WhatsApp.

"System" apps:
  • Bluetooth Scanner by Zoltan Pallagi (look for Bluetooth devices).
  • ClassyShark3xodus (from F-Droid).
  • Exodus Privacy (from F-Droid).
  • F-Droid (from F-Droid).
  • Fing - Network Tools by Fing Limited (network probe).
  • GlassWire ? A firewall/monitor.
  • Package Name Viewer 2.0 by csing.
  • Privacy Scanner from Lighthouse.
  • QR Code Reader by Scan (but some Camera apps include QR-code functionality).
  • SD Maid - System Cleaning Tool by darken.
  • strongSwan VPN Client by strongSwan Project.
  • UPnP Tool by TJ App.
  • WireGuard (VPN client; from F-Droid).
  • I haven't used it: Bouncer - Temporary App Permissions by Sam Ruston.

Audio / podcasting apps:

It seems "audio" apps just know about MP3 files. I want an app that lets me skip back and forward 15 seconds, which is hard to find. I found "Music Folder Player Free by Zorillasoft". It's okay, but has ads and way too many features for my needs. Since all it gets is MP3 files, it has no way to show any "show notes" page for a podcast. It does have skip back/forward on play.

It seems "podcasting" apps know about RSS feeds, downloading, playing or calling an external player app, maybe displaying "show notes" page. I found "AntennaPod" (in F-Droid). It has lots of features, including handling OPML feed-list files. It does have skip back/forward on play.

On desktop Linux, I use "Liferea" and "uGet" to download audio podcast MP3 files, and read web pages, from RSS feeds.

I guess I'm going to stay with Liferea and Music Folder Player, because I just have so many RSS feeds that I think I need to handle them in a desktop app, not a phone app.


+/- Some people say the AV apps are lousy, don't use them.

Anti-virus apps:
  • Anti Spy Mobile FREE by Anti Spy Mobile (checks permissions; didn't detect any of the test apps).
  • Bitdefender Antivirus Free (detected all test apps in the next section).
  • Kaspersky Mobile Antivirus: AppLock & Web Security by Kaspersky Lab (maybe detected only 2 of 3 test apps; results confusing).
AV-Test's "Here's how well 17 Android Security Apps Provide Protection"

Test apps:
  • F-Secure AV Test by F-Secure Corporation (should be detected as malware by AV apps; very small; AKA "AV Test App").
  • Test Virus by Itus Mobile Security (should be detected as malware by AV; has some extra tests you can run).
  • Test your antivirus by Guillermo Hernandez Cabrera (should be detected as malware by AV apps; has some extra tests you can run, but I don't see anything happen).
Web site that does various tests: AMTSO Security Features Check Tools

If you just put the EICAR files and some non-Android virus files on the phone, say in the Internal Storage / Android / Data folder, they don't get detected.

ashishb / android-malware (live malware; don't install any APKs)

Might be interesting:
"MacroDroid - Device Automation" by ArloSoft Tools
Joe McCrossan's "How to Use Shelter to Sandbox Apps on Android"

See Smartphones section of my Computer Security and Privacy page.

Remove Apps

How to identify apps:

  • Best way: install Package Name Viewer 2.0 app.

  • Go to Settings / Applications and click on each app you don't recognize.

    But you will get little information about each.

    Many are pre-installed and can't be removed, or even deactivated. Some can only be reverted to the original factory version, which seems useless.

  • Go to Google Play Store, then My Applications.

  • Using ADB:
    1. Install ADB on computer.
    2. Enable USB debugging on phone.
    3. Connect via USB cable.
    4. adb devices
      You should see just one device listed.
    5. adb shell pm list packages
      Mohamed Ibrahim's "Android: ADB - List Installed Package Names"
    6. Find the package name of the app you want to delete, in the list.

Vivek's "3 Ways to Find Out Android App Package Name or Android App ID"

Typical apps:

  • Android: Beaming Service (NFC).
  • Bixby (smart assistant)
  • Wake up by voice
  • Samsung voice input
  • Galaxy Store
  • TouchWiz (launcher)
  • Knox (security)
  • Good Lock (replacement for TouchWiz)
  • OM Customize
  • Game Optimizing Service
  • Smart Switch (for migrating from a non-Android phone)
  • SmartThings (home automation).
  • Jooble (job-seeking)
  • Google: speech synthesis
  • Nextdoor (neighborhood watch/trade)
  • Start ?
  • Lite: Facebook Messenger ?

Apps I want to delete:

  • Backup and Restore: com.mediatek.datatransfer
  • DG Xender: cn.xender
  • Duo:
  • GMail:
  • Google Drive:
  • Google Play Movies & TV:
  • Google Play Music:
  • Google Text-to-speech Engine:
  • Hangouts:
  • YouTube:
Sarang's "List of Bloatware you can Remove or Uninstall from your Android device Without Root"

But after deleting GMail and Google Drive, they came right back (maybe upon next reboot, not sure).

Substitute apps to get more privacy:

  • YouTube: use NewPipe from F-Droid.
  • Maps: use Osmand from F-Droid.

Brendan Hesse's "Remember to Delete and Unlink Your Accounts Before Deleting an App"

What you can do to each app:

  • Disable it: leave it installed, but not running.
  • Delete it: uninstall it completely.
  • Any way to use parental controls to disable an app ?

Go to Settings / Applications and click on each app you want to disable or delete. See what options are available.

Potential problems:
  • Other apps may depend on some app or service you want to remove.
  • Many are pre-installed and can't be removed, or even deactivated.
  • Some can only be reverted to the original factory version, which seems useless (but it might free some memory).
  • Sometimes you can disable or delete an app, only to have it come back to life later (after you use another app, or after you reboot the phone).

How to disable apps:

  • Go to Settings / Applications and click on each app you want to remove. See what options are available.

  • Using ADB:
    1. Install ADB on computer and connect to phone (see Using adb (Android Debug Bridge) section).
    2. adb shell pm disable-user --user 0 PACKAGENAME
      If package name is right, get "Success".
      If name is wrong, get "Failure [???]".

Adam Conway's "How to disable any pre-installed system app bloatware on Android without root"
Convenient but maybe dangerous: Universal Android Debloater (adb script)

How to delete apps:

  • Go to Settings / Applications and click on each app you want to remove. See what options are available.

  • Using ADB:
    1. Install ADB on computer and connect to phone (see Using adb (Android Debug Bridge) section).
    2. On phone, go into Settings / Apps / theappname, and do Disable and then Force Stop ?
    3. adb shell pm uninstall PACKAGENAME
      If package name is right, get "Success".
      If name is wrong, get "Failure [DELETE_FAILED_INTERNAL_ERROR]".
    4. Alternate method that probably won't work on system/pre-installed apps:
      adb shell am start -a android.intent.action.DELETE -d package:PACKAGENAME
      If package name is correct, get a "Do you want to uninstall this app ?" pop-up on the phone.
      If package name is bad, get an "App not found" pop-up on the phone.
    5. You may see the removed apps still appear in certain lists, with small amounts of storage assigned to them. You could try going into your computer's File Explorer, going to the phone's storage folders, and deleting any folders you see corresponding to the deleted packages, under the InternalStorage/Android/data, InternalStorage/Android/media, InternalStorage/.install, and InternalStorage folders.
    6. You may see the removed apps still appear the main list of apps. Try going into Settings / Apps, clicking on the app, and clicking Disable.

  • Instructions from a post somewhere:
    1. Only if your device is rooted.
    2. Download and Install Titanium Backup from the Play Store.
    3. Enable USB Debugging under Developer Options.
    4. Open Titanium Backup and Grant Root Access.
    5. Go to the Backup/Restore Tab.
    6. Find the app you want to delete.
    7. Select Wipe Data.
    8. Select OK on the Backup Prompt to continue without backing up.
    9. Do the same with the Un-Install option.
    10. Restart.


+/- Settings / Developer options / Take bug report and "adb bugreport DESTFILE" don't do anything on my phone. If omit DESTFILE, name should be On my Android 6.0 system, "adb bugreport >bugreport.txt", and you get an 11 MB file.

adb shell ls -R /
adb shell

adb shell pm list packages
adb shell pm list packages -f

RMG's "30+ Most Used ADB & FastBoot Commands for Android 2019"
Mohamed Ibrahim's "Android: ADB - List Installed Package Names"

Android Developers' "Capture and read bug reports"
Android Developers' "View on-device files with Device File Explorer"


getispinfo's "How To Unlock Your Android Phone If Your Forgot Your PIN"

Whitson Gordon's "How to Speed Up Your Old or Sluggish Android Device"

David Nield's "Here's How to Get Android Apps Running on Your Laptop"

Brendan Hesse's "How to Run Diagnostics Tests on Your Smartphone"

If you accidentally delete lots of photos:
"DiskDigger photo recovery" app

Google's "Help protect against harmful apps with Google Play Protect"
Jason Cipriani's "How to check your Android phone for malicious apps" (Google Play Protect)

Jonah Bellemans' "Backdooring Android Apps for Dummies"

From Daniel Micay (lead dev of GrapheneOS, I think) on reddit 4/2019:
Re: OS Security: iOS vs GrapheneOS vs stock Android:

Android is not a single operating system but rather a family of operating systems conforming to the "Compatibility Definition Document". Google builds the OS for their first-party devices from the Android Open Source Project with the addition of a directory with proprietary Google apps and resource overlays replacing the AOSP sample apps. That means the stock OS on Pixels is essentially AOSP, but that isn't the case for other devices. There's a drastic difference between the current version of AOSP with ongoing support and the sketchy forks of the OS on most other devices with tons of added attack surface, rolled-back security features, poorly-written code and a lack of security updates or major upgrades. I will assume that by Android you mean AOSP or the stock OS built from AOSP + Google apps on Pixels, rather than Android as an operating system family. That means my statements do not apply to forks of the OS on other devices.

It's also important to note that lots of privacy and security is tied to firmware and hardware rather than the OS running on it. The Nexus 5X and 6P were the start of addressing lackluster firmware and hardware security, but they didn't move the needle much. Pixels have drastically improved it and each generation has added compelling hardware security features and improved the existing ones. The firmware / hardware security has also been tightened up a lot, despite some regressions like added attack surface in the boot chain.

AOSP has gone through extensive privacy and security improvements over the past few years, and there are huge privacy improvements coming with Android Q that dwarf the progress in past years. A Pixel 3 fares very well on the security front when comparing to a current generation iPhone at the software level. It's catching up at the hardware level too, and matches most of the hardware security features.

The Titan M is definitely competitive with the SEP in terms of functionality and security. On the other hand, other aspects of firmware / hardware security are lackluster compared to the iPhone. I definitely trust Apple more with setting up proper IOMMU configuration, etc. at this point. Their more-specific focus also means less attack surface in the firmware such as the boot chain. Google has a lot of work to do as they take more control over the hardware and are able to properly harden it. Google and Qualcomm generally do a very good job, but things sometimes really fall apart at internal / external organization boundaries especially with peripherals from other companies like Broadcom Wi-Fi. Apple is better at managing the whole stack from top to bottom and avoiding some of the pitfalls that have been issues on Pixels.

I would say that when comparing only security of the OS and hardware on a Pixel 3 to an iPhone with iOS, the Pixel fares well and trades blows with the iPhone. There are areas where it does better, and areas that it does worse. It's a very complex story and it's very difficult to boil it down to a clear answer. I'm not going to go into any depth about it because it's too much. It's not something you can really ask on reddit since a book could be written about it and would constantly need to be updated / rewritten. I can give you my opinions at a high level, but if you want details you'll need to do the research since I can't spend all year writing about it.

iOS definitely does still offer better privacy from apps and their services are generally more privacy-respecting than Play Services. However, a lot of the invasiveness of Play Services is really opt-in or opt-out just like comparable analytics, etc. on iOS. It has privacy issues, but a lot of the claims about it are misinformation and it's possible to set up a Google account and stock device to be fairly privacy-respecting. I prefer devices without Play Services, but there are comparable issues in Windows, macOS, iOS and even Linux distributions, etc. Play and Google apps are particularly bad offenders in terms of nagging you to enable privacy-invasive features, and having some bad defaults. Usually they get you to opt-in to the truly privacy-invasive bits, but the nagging means most people end up doing it, since otherwise you'd need to actually disable some of the notifications which most people probably don't even know how to do.

GrapheneOS starts from AOSP without adding in the proprietary Google apps and services. It's focused on privacy and security-hardening to improve the OS from the baseline. It also preserves all the standard software and hardware security features, unlike other alternative operating systems. In the past, the project has made substantial improvements that definitely change the picture when it comes to OS privacy and security. However, it has only recently been revived and has a long way to go to reach that point again and surpass it by becoming a much broader project with a strong development team. There is a limited scope to what can be done by only a single (more than) full-time developer with some external code review and contributions. The goal is largely advancing mobile security as a whole including landing lots of features upstream and doing a lot of useful research and engineering work advancing the status quo everywhere. The project has been very successful at doing that in the past, while also offering a compelling OS. I would say that once everything is added back, it compared very favourably to iOS, and Pixel hardware is good enough to make it a decent alternative. It's not currently at that point again. I'd definitely say that once it's fully revived and going again, it will be significantly harder to remotely or locally exploit than iOS.

A major caveat to all of the security questions is that people are often not compromised with an exploit. Even a targeted activist / journalist will often be compromised by tricking them into giving up credentials, installing a malicious app and granting it permissions, etc. Android permits users to grant a lot more access / permissions to apps. This has been changing, and Android Q locks things down much more. Still, it offers users more control and freedom than iOS. You can also sideload apps, rather than only installing them from whitelisted sources / signatures, which protects users from themselves but also enables censorship and banning apps. It basically forces it since you put yourself in the position of a moderator, and are pressured by governments and other organizations to ban apps. It also achieves very little in terms of securing the system since so many of those apps have vulnerabilities / trivial arbitrary code execution. It mostly just polices what people are allowed to install, and many malicious apps / updates will still get through review. It's hard to distinguish malice from incompetence too. Competence malice looks like unintended bugs if you even find them which you probably won't. It's a trade-off in the design. ...

Android is not really "Linux". It's a Java run-time on top of the Linux kernel.

Ron Amadeo's "Google outlines plans for mainline Linux kernel support in Android"

Internals and filesystem:
K3A's "Missing Android manual"

Possible next-generation from Google:
Quarkslab's "Playing Around With The Fuchsia Operating System"

From someone on reddit 9/2020:
> Why is it so difficult to put a Linux distro on an Android device ?

First of all, the portable device can not discover its internals like a PC can. It needs data (embedded in bootloader) which describes where everything is: storage, screen, radio, etc. You may think that the data is unique for every model of the device. Wrong: sometimes it is unique for every production batch of a model, if the manufacturer had to change literally anything.

Changing the bootloader is a very risky operation: if anything goes wrong, the device is dead. No second attempts, no factory resets, nothing.

You may use the manufacturer's bootloader, but even if it does not lock you into official firmware only, usually it only supports Android kernels.

Then come the driver problems. Many devices inside a phone do not follow any open protocol and have no open drivers. In some countries it is forbidden for a phone manufacturer to open the drivers for the actual cell module.

This page updated: May 2021