[Windows/Ubuntu] ADB and Fastboot - useful stuff for your Android

1.) Setup on Linux (Ubuntu)

sudo apt-get update 
sudo apt-get install -y android-tools-adb android-tools-fastboot

1b.) Setup on Windows

I recommend the Minimal ADB and fastboot Package by shimp208, which you can get from: https://forum.xda-developers.com/showthread.php?t=2317790.

After you've installed it, you should add the folder of the installation to your PATH Variable: Press WIN+X Key, choose System, Advanced Systemsettings, Advanced, Path Variables - or just press WIN+R and enter "C:\Windows\system32\rundll32.exe" sysdm.cpl,EditEnvironmentVariables- you will need to click on the entry Path in the User Variables, edit and then create a new entry by clicking on new. There, you'll need to enter the path to Minimal ADB and Fastboot, i.e. C:\Program Files (x86)\Minimal ADB and Fastboot, click ok and close everything. Now you can use adb and fastboot from CMD in every folder.

 

2) Using it!

ADB can be used to do almost anything with Android Devices - as long as Android Debugging is activated. Developer Mode is activated via Settings -> Status and clicking 7 times on "Build number". After that, the Developer Options are available in the Settingsmenu. In this menu, you need to activate Android Debugging and connect your Phone via USB to your PC. You can start i.e. the Android Shell by accessing your Terminal and starting adb shell

In the Android Shell, you can navigate the file system of your phone or change different settings, i.e. you can change the brightness of your screen via:

settings put system screen_brightness 200

There are a lot of settings you can change, some are listed here:

Settings System: https://developer.android.com/reference/android/provider/Settings.System.html

Settings Global: https://developer.android.com/reference/android/provider/Settings.Global.html

Settings Secure: https://developer.android.com/reference/android/provider/Settings.Secure.html

You can also get a list of your current settings with settings list [namespace], i.e.

settings list system

You can also reboot your phone if it is rooted, move files, edit them, delete them - everything you can do on a normal linux system.

Another useful adb commands are pull and push. With adb pull  you can pull a file from your phone to your pc. And with adb push you can upload a file to your phone.

Also, you can adb install  install apk files / apps or adb uninstall  uninstall them.

Important for debugging is the access to the logcat daemon via adb logcat so you can see what happens on your phone. You can even filter for different apps, i.e. chromium: adb logcat -s chromium

There is a bunch of other goodies like forwarding socket connections or reverse sockets and backup / restore of apps - which you can find out by looking at the useful adb help output.

Fastboot is the last command I want to describe here. You can use adb to reboot your phone to bootloader (adb reboot bootloader) or recovery (adb reboot recovery). If your phone is rooted and you get it into the bootloader, you can access it via fastboot. This tool is vital to flashing new kernels, images, recoverys and other stuff if everything else fails. Knowing that it exists should be enough for the "normal status of operation" - but if something breaks - use it ;)!

Lineage OS Fix: After reboot phone not usable anymore (Only back button/statusbar visible)

Sadly, my Nexus 4 (mako) had a rough experience after upgrading to Lineage OS: After a reboot, I ended up with this screen:

As you can see, only the back button and status bar are visible anymore, I can drag down the status bar and enable / disable stuff but cannot launch the settings or anything else - brick'd :(. I had to reinstall that thing several times, but then came to the conclusion what caused the error: I had enabled a screenlock (does not matter which kind :)) and played with the System Profile under Settings. I created a second System Profile which - as soon as it connected to my Home Wifi, removed the screenlock. And that was the problem. After two additional reboots, the error as seen manifested.

Good news: It only took me three complete reinstalls (read: wipe... ^^') to get that - and the fix is very simple: Don't create such an System profile. If you have and you end up there, that is no problem as well: If you have adb Debug enabled, you'll have it fixed in one minute and one reboot:

# open your CMD / Bash
adb shell
# activate root
su
# go to the correct folder
cd /data/system/
# get your current profile config
cat profiles.xml
# now grab that config file, remove the <profile> </profile>
# part which causes the error -> your newly created profile
# with "auto turnoff screenlock"
# after that, put it back on your phone
echo 'HERESHOULDBETHENEWCONFIG' > profiles.xml
# then reboot your phone
reboot

If you have no root access available you could get root on your device via the addon from Lineage OS, and if you don't want that (which is good too!) or you got no ADB Debug enabled - fix it from within TWRP :).

PS: If you want to report something, always pass along your logcat (extract with adb logcat -d '*:V' > logcat.txtif you got adb access)

Nexus 4 / Nexus 7 CrossUpgrade from Cyanogenmod to Lineage OS

EDIT: Experimental Builds were deleted now, as initial stated by LineageOS Team in this post. CrossUpgrade is not possible anymore, best bet would be to wipe the device and start from scratch. So just skip the second step with EXP Image and WIPE EVERYTHING in TWRP and install the latest nightly. Please also stay alert on bugs which are included in LineageOS. This link will give you access to the unresolved section of the Nexus 4 / Mako device, while this link will give you access to the same for the Nexus 7 2013 Wifi / flo :). Also, you can find the latest changes for mako here and for flo here.

As CyanogenMod ended their services - and Lineage OS took over, we need to cross-upgrade to the new system.

0.) Basic idea:
To upgrade to Lineage OS, they setup an so called experimental image. This exp image exists soley for the reason of migrating old CM installations to LOS installations. An really ugly-nag-screen will remind you of that. So the upgrade path will be: CM -> LOS Exp -> LOS Nightly. Also, you need to upgrade to the correct version. I.e. LOS does supply Nexus 7 LOS 14.1 images, so you need to upgrade your Nexus 7 first to CM 14.1, then install the LOS Exp 14.1, then the LOS Nightly 14.1

1.) Nexus 4 (mako)
- Install latest TWRP Version: https://twrp.me/devices/lgnexus4.html
- Make sure your device is on CM 14.1, if not, upgrade via: https://download.cyanogenmod.org/?device=mako
- Download LOS 14.1 Exp and install via TWRP (clean caches!) and reboot: https://download.lineageos.org/mako
- Download LOS 14.1 Nightly and install via TWRP (clean caches!): https://download.lineageos.org/mako

2.) Nexus 7 2013 Wifi (flo)
- Install latest TWRP Version: https://twrp.me/devices/asusnexus72013wifi.html
- Make sure your device is on CM 14.1, if not, upgrade via: https://download.cyanogenmod.org/?device=flo
- Download LOS 14.1 Exp and install via TWRP (clean caches!) and reboot: https://download.lineageos.org/flo
- Download LOS 14.1 Nightly and install via TWRP (clean caches!): https://download.lineageos.org/flo

And thats it! 🙂

More Infos needed? Just check out this older blog entry - you can use 2) and 3) but please do not delete anything except caches on 3) - and you do not need to flash GAPPS - as we want to upgrade, not reinstall from scratch 🙂

Cleaning Cache on Android >= 6.x (Apps won't work!)

As I am quite an Twitter Addict, I tend to surf a lot on that Social Media Site, blowing my Android Cache to unfriendly-sizes. In earlier days, I installed some random Cache Cleaner from the PlayStore, cleaned the Caches and directly uninstalled those Apps again, as they tended to be full of Ads. However, in recent days, I saw that most Cache Cleaners did not work - even though "the devs said so". How come? Well, I found my answer on the Github Repo of the android-cache-cleaner: "Starting with Android 6.0, CLEAR_APP_CACHE permission seems to be no longer available to regular applications and since this permission is required for cleaning of internal cache, Cache Cleaner is not able to clean internal cache on Android 6.0 and newer. However, cleaning of external cache is still supported." Well, cool thing. So most of those apps are useless as hell. But how to clean all the caches?!

TL;DR:
You do not need [an] app anymore if you are on Android 6.0 or newer. Just go to Settings & Storage -> USB -> Internal storage and click on Cached data in order to clear all the cache.

Source: https://github.com/Frozen-Developers/android-cache-cleaner/blob/master/README.md

Nexus 4 Upgrade to CM 14.1 / Android 7.1 Nougat + Updates

[UPDATED 10.12.2016]
A little bit problematic, but... works in the end.

Warning: Bleeding Edge!
Will bootloop, you'll need to format your phone, it will break eggs, pcs, glass and burn down your house.
Comes with no support what-so-ever from my side.
You have been warned!

1.) Get all the files
CM: https://download.cyanogenmod.org/?device=mako (Latest version was: https://download.cyanogenmod.org/get/jenkins/187896/cm-14.1-20161202-NIGHTLY-mako.zip)
GAPPS: http://opengapps.org/ (ARM, 7.1 GAPPS, Picco Version)
TWRP: https://twrp.me/devices/lgnexus4.html (Download from: https://dl.twrp.me/mako)

2.) Flash TWRP
- Press Vol Down and Power Button to shut down the Phone.
- Press Vol Down and Power Button again to boot to the Bootloader
- Upload TWRP via fastboot: fastboot flash recovery twrp.img

3.) Flash and Install
- Boot to Recovery
- Delete all Files from your Phone
- Upload CM and GAPPS file via MTP to sdcard
- Flash CM, then GAPPS
- Clean Cache

4.) "Debug"
You would get an bootloop, if you would reboot now. According to http://androidforums.com/threads/twrp-bootloop-fix-after-update-ota.922585/ you need to go to the Terminal (or adb shell) and enter following commands:
dd if=/dev/zero of=/dev/block/platform/msm_sdcc.1/by-name/fota
(enter) - and then
dd if=/dev/zero of=/dev/block/platform/msm_sdcc.1/by-name/misc
(enter)

5.) Reboot
And you're good to go. However, somehow the update functions are bricked, so... check out the forums and bug reports:

http://forum.xda-developers.com/nexus-4/orig-development/official-cyanogenmod-14-1-nexus-4-t3507532/page7
https://www.cmxlog.com/14.1/mako
https://review.cyanogenmod.org/#/c/173328/

EDIT / REGARDING UPDATES:
Updates seem to be bricked because of some error in TWRP which sends Android 7.1 into a bootloop after EVERY update. So if you're updating via regular "Fullsized Images" from get.cm, you need to run the 4th Section / Debug EVERY time you update! However, you can get around that, if you use CyanDelta Updater (https://play.google.com/store/apps/details?id=com.cyandelta). Just install CyanDelta Updater on your phone, choose your CURRENT cm.zip (i.e. the one you installed your phone with, in this tutorial the cm-14.1-20161202-NIGHTLY-mako.zip) and let it index that. After this, it will try to find newer CM versions on the net and only download the delta, i.e. the changes to your current image. This will most likely break down your new 330+ MB download to an about 40+ MB download (which is nice!) - and after that, you can just install the update via the same app (actually it will ask you, just give it root rights and let it do its job, next reboot will take a while, but it works! :)). In any case, the TWRP Bootloop problem is solved with that, update downloads are smaller and everyones happy ;).

IMPORTANT: Best strategy before attempting ANY kind of update would be to make a full backup via TWRP and move it to a secure location (i.e. your pc harddrive) in case you brick your phone and need to restore it! At least one backup after your initial install (with all apps and stuff) should be made. It makes life so much easier in case something goes wrong :).

Private Dropbox/Google Drive/File Sync: Syncthing

I tested quite a lot of sync tools out there: Dropbox, G-Drive, Bittorrent Sync, ownCloud, plain Rsync,... You name it.
But to be true, I never really liked any tool that much: It never really *worked out* somehow: The Mobile Apps were bad, "Servers" did eat up too much performance, etc. etc.
And we don't want to forget these little itching problems with privacy - thinking about Dropbox, G-Drive and the now closed source Bittorrent Sync...
Well - enter Syncthing: https://syncthing.net/
In truth I can only say one thing: It works. It just, plainly, works for syncing data from your mobile devices to your swarm of servers or pcs.
So give it a shot :)!

Android Failed to Build Eclipse Android Project Fix

[2013-11-02 08:26:51 - SearchViewDemo] Dx
trouble writing output: already prepared
[2013-11-02 08:26:51 - Dex Loader] Unable to execute dex: java.nio.BufferOverflowException. Check the Eclipse log for stack trace.
[2013-11-02 08:26:51 - SearchViewDemo] Conversion to Dalvik format failed: Unable to execute dex: java.nio.BufferOverflowException. Check the Eclipse log for stack trace.

Well that happend to me as I tried to build my latest project.
Solution was quite simple but... strange.
Just remove all newer Android SDK build-tools (i.e. 19) until the Version 18.1.1 with the Android SDK Manager.
Restart Eclipse. And it will work.

If not, try to add the Support Libraries (Right click on your Android Project in Eclipse, choose Android Tools, Add Support Library)

Issue and solutions found here: https://code.google.com/p/android/issues/detail?id=61710