emulator

The Android “adb shell list files permission denied” error

As a brief note, today I tried to list the files in my Android application, which was running on a physical Android device — a Nexus 9 — with this adb shell command:

adb shell com.alvinalexander.mybrowser ls /data/data/com.alvinalexander.mybrowser

When I did that, I got an Android/ADB “permission denied” error.

The short story is that a solution to this problem is to run the same command, but with the run-as argument, like this:

How to restore an Android emulator to its initial "factory" settings (wipe the data)

To restore an Android emulator to its initial, default settings, you need to find its “image” file on your filesystem and delete it. The image file will be found in your $HOME/.android/avd/<avdname>.avd folder.

For example, I was just working with an AVD named Nexus_6_API_21, and its directory on my Mac OS X system is /Users/al/.android/avd/Nexus_6_API_21.avd. I moved into that directory and found several “.img” files, deleted them, and then restarted the emulator, and it went back to its default settings.

How to copy files to an Android emulator’s data directory with ‘adb push’

As an Android developer, you can normally use the adb push command to copy files from your computer’s hard drive to an Android device. However, I just ran into a problem where I couldn’t copy files to my Android emulator’s “data” directory, i.e., the /data/data filesystem. When I tried to copy a file using this command:

$ adb push foo.jpg /data/data/com.alvinalexander.myapp/files

I got this Android error:

How to display the lock screen on an Android device emulator (keystroke)

As a quick note, if you want to show the “lock screen” on an Android device emulator, press the F7 key twice. I’m currently working on an Android notifications app, so I want to see what the notifications look like on the lock screen, and I just discovered this approach.

How to delete/uninstall an Android app from an emulator from the command line

I recently had a problem with an Android emulator, and for some reason I wasn't able to delete the Android app I was developing. I knew you could delete Android apps from the command line, but I had no need to do this until now.

After reading a few docs, I found that I could delete my Android app from the command line using the adb command, like this:

How to start the Android command line shell (adb) alvin February 5, 2012 - 10:04am

Android FAQ: How do I start the Android command line tool (so I can interact with my Android emulator or device)?

You start the Android command line with the adb shell command:

$ adb shell

This makes at least two assumptions:

  1. You have the Android SDK installed.
  2. You have an Android emulator (or physical device) running.

When you start the adb shell, you'll see a very simple prompt that looks like this:

Android emulator not loading my app

I haven't used Android in a little while now, in particular with my new laptop, and the first time I tried running an Android app from inside Eclipse, the Android emulator wouldn't finish starting properly and run my app.

I remember I used to look under the "all apps" icon, and could sometimes find my app was actually loaded, but in this case, it wasn't loaded at all.

Android + Eclipse: How to create a new Android Virtual Device (AVD) emulator

Android Eclipse FAQ: How do I create a new Android Virtual Device (AVD) emulator I can use in Eclipse?

There are at least two ways to create a new Android Virtual Device you can use in Eclipse: (a) Using the Eclipse Android GUI, and (b) using the Android command line.

How to create an AVD in Eclipse

Assuming your Android Eclipse work environment is set up properly, creating a new Android Virtual Device (AVD) is simple. Just follow these steps.