Goto hell

Small and funny easter egg I found by accident today: stop using “adb shell” to access your device. You’re wasting precious keystrokes. Instead, you should be using “adb hell”. Yes, ‘adb hell’ works just as well as ‘adb shell’ – but it’s even more awesome. Go and try it!


PSA: OEM unlocks may result in wiped filesystems

So, I bricked my tablet. Turns out the bootloader couldn’t mount /data: after doing an oem unlock thingy, /data gets wiped and (this is the part the manual I was following didn’t warn me about) no filesys is created.

If this happens, go back to recovery mode, then adb shell and run ‘mount /data’. This will give you an error like “Can’t mount /dev/block/mmcblk0p23”. Write down the /dev/block id and run ‘mke2fs -t ext4 /dev/block/mmcblk0p30’. That should fix it.

In some systems you may be missing libext2_quota.so. If this happens, just look for libext2_quota.so in the interwebs, then adb push this file into /sbin.


VLCFreemote: no need to leave the couch

I’ve been quite prolific in my Github account recently, if I may say so myself. The latest of my open-source projects which I think is more or less ready to be “released to the world” is VlcFreemote, a remote control for VLC in Android. From its README file:

How many times have you been comfortably watching a movie from the couch only to find out you forgot the subtitles? How about being snugly tucked under a blanket, only to find out you need to brave the cold of winter just to add a new episode of your latest binge-watching series? Yeah, that can easily ruin your day.

Worry no more: with VlcFreemote you can now install a tiny Android app to control your VLC server.

FAQ:

  • Another VLC remote? Why?There are a few VLC remote controls out there. I think this is the only once that’s open source (not 100% sure). It has some nice extra features I haven’t found in other remote controls too: bookmarks, automagic movie-skip (jump forward by a percentage of the file length, much more useful than it sounds!) a compact layout and other small things probably not even worth mentioning. In the future, whenever I get some free time, I’d like to add the ability to start VLC automatically from SSH, a feature I would use a lot and I have seen nowhere else.
  • Why isn’t this in Google play?Mostly cause I’m lazy and cheap. Getting a Google Play account costs 10 dollars or so, and I’m too lazy and too cheap to get one. Want me to upload it to Google Play? Feel free to buy me a beer. If not you can just get the APK from Github, or download the source code and build it yourself.

Android studio and ndk-gdb to debug a native app

I don’t know how good Android Studio support for native apps is nowadays (it changes from week to week!). Up to a few months ago, Gradle, the build system used by AS, had poor support for native development. If you’re having problems, you may find it easier to workaround it completely when it comes to build and debug C/C++ applications.

To debug a native Android application, a binary called gdbserver and its associated gdb.setup must be included in the generated APK file. Including this into the APK can be very painful in Gradle, so here’s a workaround I found:

  1. Build your stuff the way you normally would (I’m assuming you know already how to build a native app, and if you don’t there are guides online that explain it much better than I could).
  2. Deploy your application the way you normally would.
  3. Discover ndk-gdb won’t run. Bang forehead against keyboard a few times.
  4. After losing some hours looking at logs, figure out there’s no gdbserver included in your apk.
  5. Lose some more hours trying to figure out how to include it in your apk using Gradle.
  6. Give up. Bang forehead against keyboard some more.
  7. find the gdbserver and gdb.setup in your build directory.
  8. adb push each of these files to the device.
  9. Using adb shell, move the files you copied to /data/app-lib/com.yourapp/ – you may need to root your device for this.
  10. Profit! ndk-gdb now works.

 

Edit: remember you may need to chmod +777 your gdbserver.

 


ndk-gdb life tip: use –verbose

Crosscompiling is always fun. No matter how ready-to-use it’s packaged, and Android does a pretty decent job at that, you’re still bound to find problems that leak through the abstraction layers. If something says it’s dummy-proof, I always find the way to perfect myself and be even dumber. For people like me; do yourselves a favour and start launching ndk-gdb this way:

ndk-gdb --start --verbose

Using the –verbose parameter will probably reveal some hidden errors. For example, when I forgot to chmod 777 my gdbserver binary:

## COMMAND: adb_cmd pull /system/bin/app_process ./obj/local/armeabi-v7a/app_process
run-as: exec failed for /data/data/com.nico.trippingsdcardphotomanager/lib/gdbserver Error:Permission denied
117 KB/s (9560 bytes in 0.079s)
Pulled app_process from device/emulator.

I now write Android apps: presenting Tripping Photo Manager

I have been working in an awesome Android app recently, so I’d like to throw in a shameless self-plug here. Oh, wait, it’s my blog. It’s all basically a big shameless self-plug, isn’t it? Anyway, I’ve been working on https://github.com/nicolasbrailo/TrippingSdCardPhotoManager , an open source SD card photo manager for Android.

Why an SD card photo manager? Whenever I go on holidays I never have enough SD cards to store all the snaps I take. Luckily I’m a crappy photographer, so I end up deleting half of the pictures I took during a day. This makes it easy to somewhat re-use the same SD card. In my experience, Android is not always great when it comes to managing files from an external SD card mounted through an USB adapter, hence this little app was born: it’ll let you select the directory you want to use to manage pictures, from anywhere in the filesystem. It’s also somewhat faster than the native gallery app, which is a plus when working with a slow-ish SD card.

This app also supports some stuff I find useful in my workflow, like renaming the current directory to something more meaningful than “YourCamera4242”, backing stuff up in the device and batch deleting files. It also packs a version of ImageMagick I ported for Android, so in theory you can use your Android device to do anything you can do with a regular “mogrify” command in Linux.

The app is not available in Playstore, mostly because I’m a cheap bastard and don’t want to pay the 10 bucks Google charges you to create an account, only to publish an open source application.

You can still install the APK from this link: https://github.com/nicolasbrailo/TrippingSdCardPhotoManager/releases
– or you can contribute to the open source world (?) and buy me a Play Store account.