[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 ;)!

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 :).

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

[Win7] Upgrade Error in Android SDK for Windows

Recently I got an error on trying to upgrade my Android SDK, claming that I would not be able to access an URL. I was looking around the Internet and got the information that I should first upgrade the Eclipse Plugin. OK!

Upgrading AVT:
1. In Eclipse go to Help
2. Install New Software ---> Add
3. inside Add Repository write the Name: ADT and Location: https://dl-ssl.google.com/android/eclipse/
4. after loading you should get Developer Tools and NDK Plugins
5. check both if you want to use the Native Developer Kit (NDK) in the future or check Developer Tool only
6. click Next
7. Finish and Restart Eclipse

Source: http://stackoverflow.com/questions/14869929/update-android-sdk-tool-to-22-0-4latest-version-from-22-0-1

Ok, that got my Plugin to the latest version. But I still could not upgrade to the latest SDK. And thats when I found out that you need to start the SDK Manager as Administrator (right click, run as Administator) - and voilá: Upgrade successfully.

Source: http://stackoverflow.com/questions/4771895/android-sdk-manager-not-installing-components

[Android] Install FroyoMod onto Motorola Milestone

This document does explain in short how you install the popular FroyoMod onto your Motorola Milestone.
( Froyomod does use Android 2.2.2 )

- install RSD Lite v4.9
- download and unzip vulnerable_recovery_only_RAMDLD90_78.zip
- download androidiani-openrecovery ( http://code.google.com/p/androidiani-openrecovery/ ):
unzip into root of your Android SD ( update.zip + OpenRecovery Folder )
- Download Bootimage for your Droid (http://forum.xda-developers.com/showthread.php?t=815595) und verschieben auf SD nach /sdcard/openrecovery/updates ( Zip nicht entpacken! )

- Shutdown Phone, Connect USB, HOLD D-PAD UP, Power on
- RSD Lite Flash Vulernable, Hold D-PAD UP on Reboot -> Boot to Boot Loader (OTHERWISE: OTA LOCK!)
- Shutdown, Hold Camera Button + Power Button (or X+PWR), Maintance Screen comes up. Press Speaker U+ Camera, choose with D-Pad apply sdcard:update.zip and click
- Backup: Recovery, Recovery All
- Wipe: Wipe Dalvik, Wipe Cache und Wipe Data/Factory Reset
- Flash: Apply Update

Thats it!
You don't need to do full wipe all the time if you change within version.

If you need QWERTZ Hardware Keyboard: Within OpenRecovery: Settings > Keyboard Layout > qwertz