Showing posts with label Android. Show all posts
Showing posts with label Android. Show all posts

Wednesday, June 15, 2011

ADB, Eclipse, and Android SDK the Easier Way

Update:  For an even easier installation process, use my 32-bit or 64-bit .deb installers.  Just double click on them and follow the prompt.


Outdated Information: (still works, but not as easy)

Easy Access Links: *** Please read the installation instructions at the bottom of the page. Also the long version is designed to talk you through every step of the process. The short version is for people that just want the abridged version that are comfortable with Eclipse or Terminal. ***


GitHub (if you know how to use it)

If my script has been helpful to you, feel free to donate to the cause.


Changelog



  • 1.0.3 (6/18/2011) - Setup 99-android.rules automatically, created a symlink for ddms so it can be executed from anywhere -- has to be typed twice sometimes the first time it is run for some reason (multiple displays error).
  • 1.0.2 (6/17/2011) - ./android update adb wasn't launching properly.  *Should* now.  The script should end with Eclipse wanting you to install Android SDK Platform-tools.
  • 1.0.1 (6/15/2011) - ./android update adb added to script.  Eclipse interaction minimal.
  • 1.0.0 (6/14/2011) - Android SDK, Android NDK, Eclipse, ia32-libs automatically installed.  Eclipse and ADT require prompting.


Introduction

Now that I've finished my first release of the script, it has gone through some testing on 64-bit and 32-bit Linux Mint 11 systems and the installer seems to work. Now I wasn't able to completely install ADB with this script because I haven't been able to figure out a way to configure Eclipse from within the script, nor do I know if it is possible. So there is SOME work that you will have to do. I started learning how to program about 5-7 days ago and that was when I set out to make this script. That said, there are bound to be some errors that arise that I probably cannot fix.

BORING STUFF

One thing I'd like to discuss is the logic of the script (skip ahead if you just want the download link and instructions). I wanted to make it so the script could be run multiple times on accident and error check itself. I also wanted to make sure that as long as you had the Android SDK or NDK that you would not encounter problems with them installing again on my script. This will also carry over to any other of my scripts that I plan to make that will call on either of these libraries.  The following files will be installed by the end of the script:  Android SDK, Android NDK, Eclipse, and for 64-bit systems ia32-libs will be installed.  An ADB environment will also be set up so that once the script has been run and terminal has been restarted you will be able to run ADB anywhere by simply typing "adb" after setting up Eclipse.

Things Changed on Your System and Instructions



  • To access Android Debug Bridge at anytime after the script has been run and your terminal reset (bash typed or terminal closed and opened) you can type the command "adb" from any location.
  • To access the Dalvik Debug Monitor, you can access it by typing the command "ddms" and if you get an error about multiple displays then type "ddms" again and it should start.
  • To reference the Android SDK to compiling something, it will be located in the following directory: /usr/local/android-sdk
  • To reference the Android NDK for compiling something, it will be located in the following directory: /usr/local/android-ndk
  • Eclipse is now installed and most likely located in Applications -> Programming.
  • 64-Bit Operating Systems had the package ia32-libs installed for compatibility reasons.


INSTALLATION INSTRUCTIONS (Short Version)
These instructions are for people that are able to more confident with Terminal and Eclipse.  The instructions are not overly complicated, but I have provided a more in-depth tutorial for those that need it.


  • Download the file
  • chmod +x installer.sh
  • sudo ./installer.sh
  • Install "Android SDK Platform-tools" and accept the licensing agreement.
  • *** Close all instances of Terminal once this is done or type bash ***
  • Test ADB in terminal by typing "adb" from any directory. (without quotes)

INSTALLATION INSTRUCTIONS (Long Version)

If you have a GitHub account then you can download the latest version of my code from this link.  That link should provide the latest version of my code when and if I need to make any changes.  The other link that will probably not be updated as frequently is this dropbox link.  If you're getting the code from GitHub, for the sake of this tutorial I will assume you know how to obtain the file.

Step #1:  Download the file and find it in terminal.

When you open terminal, you will need to find where the file is located.  If you're using Linux Mint 11 and Google Chrome, it is most likely going to be in the "Downloads" folder (case sensitive, no parenthesis).  We can change to this directory in terminal by typing "cd Downloads" (notice that the Downloads has a capital D).  You can list the file and directories by typing the "ls" command.

Step #2:  Grant executable properties to the installer.

Once the file has been found and you're in the same directory type the following commmand:

chmod +x installer.sh

Step #3:  Install the file and go afk.

This part takes a long, long time depending on how fast your internet connection is.  Even longer if you have a 64-bit operating system (Don't worry!  The installer figures that out for you!) and has to do a lot of things right now.  You can either read ahead or go do something fun, I'd suggest the latter.  So to initiate this part type the following command and then enter your password:

sudo ./installer.sh

Notice how there is a period and then a forward slash before installer.sh?  Very important to put those in there.

Step #4:  Install Android SDK Platform-Tools


The Android SDK Platform-tools contains the ADB.  Also, if you plan to do any developing in Android this screen will probably be of some use to you.  Start by selecting "Available packages" from the left side and then under Android Repository install the "Android SDK Platform-tools."






Android SDK AVD Manager Eclipse Linux Platform Tools


Accept the next screen and if you have a pop up that asks if ADB can restart say "Yes."  Close out of Eclipse if you are done with it.

Step #5:  Test ADB and Done!


IF YOU HAVE ANY OPEN TERMINAL WINDOWS RIGHT NOW CLOSE THEM TO REFRESH THE ADB ENVIRONMENT.  Open terminal and type "adb" without the quotes (it doesn't matter which directory you do it from).  You should see a bunch of commands go across your screen to indicate that it worked like below:






adb google sdk android eclipse ndk linux

If "adb" doesn't prompt anything, try typing "bash" first and then type adb again.

Sunday, June 12, 2011

Just a little talk about a side project

Since I have been working more on Linux and Android together, I just wanted to keep people up to date on what I've been doing with my projects and the website. I managed to get the VLC source code compiled into an APK and working. It runs smoothly for various formats, I'd like to do a write up on how I got that working soon and also make an automated script to download the lasted script from their git repository. My hope is to allow the user to learn about it and also give them a quick alternative to updating their APK for the phone that they can swap out for the latest build of VLC while it's still in the alpha state.

The other thing I've been working on is automating as much of the Android SDK / Eclipse process as possible for people that want to start programming and are afraid to come to Linux. I want to do this because I love the idea of an open source community, be it in Linux or Android and really want them to thrive. Linux can be intimidating when you first start using it and can require you to format your computer every time you screw up your system. At least until you figure out the file system and then you can fix almost every problem pretty easily. Google however, seems to make it fairly difficult for a first time person coming to Linux to start programming and I'd like to try to bridge that gap by automating as much of the Eclipse set up as necessary to get more developers working on Android in a Linux environment. I don't know if I'll be able to automate everything required to get a system installed with ADB, but possibly one or two steps away and just requiring GUI interaction in Eclipse (I'm still researching this part, to see if I can do any of this).

In the mean time, if you'd like to make any suggestions for write-ups I'll gladly take suggestions in the comments section or on twitter at @ArchDukeDoug (still waiting for the title to be granted in any country, probably not going to happen). Suggestions allow me to help you and also help myself, so don't be shy with them. If I'm able to do them I will definitely try.

Sunday, June 5, 2011

Sync Music to your Android OS Device in Linux with Banshee Media Player

I always had a hard time finding a way to sync my music and playlists easily to my Android phone in Windows. I tried using Doubletwist, Winamp, and even some strange AdobeAIR playlist editor. There was just never a clear cut way to go back and forth with my playlist. Once you figure out how to get Banshee and your Android phone on the same page, the two coexist wonderfully with only a few exceptions. "What are those exceptions?" You might ask. Or you may just skim past this and completely ignore this part and figure out that it's difficult to sync certain file types later. Those exceptions are that you have to edit a file with the MIME Type of the extensions that you want to add. I'll give you a sample of the file I used which includes as many of the MIMES as I could think of at the time and try to include an example in case I missed one so that you can add more to the list.

First thing we want to do is switch Banshee to daily build to get the most up-to-date version. To do this open up terminal and type:

sudo add-apt-repository ppa:banshee-team/banshee-daily
sudo apt-get update
apt-get upgrade

If for some reason Banshee is not installed right now (it is by default with Linux Mint 11), you can install it with: sudo apt-get install banshee

Now connect your phone by USB to your computer and set your phone to USB Mass Storage. Open the root SD card directory with nautilus and create a new empty file (right click -> create document -> empty file) called .is_audio_player and edit it with gedit.



is_audio_player for android phone


In the empty gedit file put the following information (like above) into the text file:

audio_folders=Music/, Video/

folder_depth=2

output_formats=audio/mpeg,audio/mp3,audio/x-aac,audio/ogg,audio/aac,video/mp4,video/mp4-generic,video/mpeg4,video/quicktime,video/x-matroska,audio/x-matroska,video/vnd.avi,video/avi,video/msvideo,video/x-msvideo

Adding the file to the folder allows Banshee to see that your Android phone is actually a music player. Editing the contents of it will tell Banshee what file formats that the phone supports. The one format that I've had trouble getting to work are *.avi because they use different codecs and I get an error. Now start Banshee up and you should see your phone listed under "Devices" now.



Banshee Media Player Sync


You can import the music from your phone by right clicking on right clicking on the x GB Filesystem and selecting "Import to Library" and that will copy all of your files into the folders. Otherwise you could manually copy the folders from your SD card to the ~/Music and ~/Video folders as well as the playlists and import them into Banshee. If you're importing a playlist, you need to open the playlist with gedit and convert all of the backslashes (\) to forward slashes (/) with the search -> replace -> replace all feature. Once you've replaced all the slashes, try importing the playlist under File -> Import Playlist (try doing them one at a time if you have problems with them leaving songs out).

That's it.  Your device should now be capable of syncing to your Banshee Media Player.  It may take a little playing with to get the playlists set up for your device and your music set up in Linux and organized.  Your videos may also error out depending on if it is supported by the .is_audio_player.

** Extra Notes**

If your video is unsupported by Banshee, you can try adding the MIME-Type to the .is_audio_player by following the format: video/name or audio/name and you can find the name from looking up the extension on wikipedia.  For example:  audio/mpeg,audio/x-wav,video/mpeg,video/quicktime

I believe Apple devices (iPhone, iPad, and iPod) should all work out of the box with this program because of a plugin that comes installed by default.  I'm not 100% positive though, but under Extensions there is one listed for Apple Devices Support listing the three I previously mentioned.  I just am not sure what is required to set that up.

Saturday, May 28, 2011

SBFing the Droid X using Linux Mint

I thought I would help contribute to this by writing a post about SBFing the Droid X using Linux Mint. This is particularly relevant considering A) I had to do it today and B) the 4.5.596 Gingerbread update did NOT change the bootloader for those of us with a Droid X, so we can still SBF back to Froyo when we screw up our phones (like I did this afternoon). The best part about SBFing with Linux is that now that you've (hopefully) learned some of the ins and outs of the operating system from the earlier posts, I think you'll find that the SBF process is much more hassle-free with Linux than it is with Windows.

As far as software, you will need:
  1. sbf_flash utility. This can be found here.
  2. The actual SBF file. Make sure you get the right version. I recommend the Android 2.2.1 System Version 2.2.340 Full (VRZ_MB810_2.3.34_1FF_01) (Current OTA) for best results. This can be found here. It can take quite awhile to download, so just be prepared.
On the phone end, you will need to have:
  1. Your Droid X, preferably fully charged. If your battery is low, you will not be able to SBF. I've never done this with less than 90%.
  2. A USB cable. Plug this into your computer, but hold off on plugging it into your phone just yet.
Start off by powering down your phone. Hold the camera button and the volume down buttons at the same time. Then hold the power button. The screen will likely flash for a second - now let go. The bootloader screen will pop up. It will say Bootloader: 30.04, several spots of black screen, and then Battery OK, OK to Program, (assuming your battery is in good shape) and Connect USB Data Cable. So far so good!

Now open a terminal window. You'll want to navigate to the directory where you've placed your sbf_flash utility and your SBF file. I made a folder called ~/sbf. Once you're in the correct directory, you can type the following command:
ls
This will list the files in the directory. You should see sbf_flash and VRZ_MB810_2.3.34_IFF_01.sbf. Now type the following:
chmod +x sbf_flash
If you've been following the blog, you've seen this before. This simply makes the sbf_flash utility executable to run as a program.

Now, connect your Droid X via USB cable to the computer. It should show on the screen that it is connected! Once it is connected, type the following command into the terminal window you still have open:
sudo ./sbf_flash VRZ_MB810_2.3.34_1FF-01.sbf
Your terminal window should look something like this:


The phone will now begin the SBF process (after you enter your password). I would like to note here that after the SBF process is complete, the phone will reboot. Once the phone reaches the boot animation (i.e. the scary Droid eye) I always unplug my USB cable. I have never been able to SBF without immediately bootlooping after, so for others who have similar problems, this is the solution:

  • During the boot animation, pull the battery.
  • Return the battery to the Droid X.
  • Hold down the home key, then hold down the power key. Wait until the Android logo with a triangle and an exclamation mark pops up.
  • Now press the search key. This is what is known as stock recovery, just in case you haven't seen it before.
  • Scroll down to "wipe data/factory reset" using the volume buttons, and select it using the camera button.
  • When it is finished, press the camera button on the "reboot now" option. The phone should reboot successfully.

Congratulations, you have just managed to SBF using Linux Mint!

Monday, May 23, 2011

Installing XBMC Media Center for a Home Theater PC

Some of you may have blu-ray players, HDMI out, music, pictures, and videos on your computers that you would like to watch on your TV (or monitor). That's where XBMC comes in. It's a browser that is capable of displaying the weather, downloading a vast array of plugins and scripts (such as youtube and engadget videos), combining the contents of a group of folders (e.g. E:\Movies1, ~/Movies2/, and smb://networkcomputer/movies3/) that would be displayed alphabetically as a folder listed as Movies in within XBMC, an easy download subtitle script, and more.

XBMC is a very nice program for people interested in organizing their media. I've been using it for a few years now. I bought a $20 infrared remote off Newegg.com. This is not necessary - you can still use a physical or wireless keyboard and mouse but having a remote with a pause button on it adds to the experience.

Installing XBMC is currently very easy. We'll be using the unstable Team XBMC repository because as of writing this, there is no stable version released for Natty Narwhal (Linux Mint 11 is based on Ubuntu 11.04 and can use all of their repositories and their own as well.) If you'd like to check for a stable release before doing anything, you can just try typing xbmc in the Software Manager and see if anything comes up. If not, lets continue on with installing the unstable repository and XBMC Media Center. Open terminal and type the following (3) commands:

sudo add-apt-repository ppa:team-xbmc/unstable
sudo apt-get update
sudo apt-get install xbmc

Once it is installed, close terminal and you will find XBMC installed at Menu -> Sound & Video -> XBMC Media Center.



This is the main screen and the default skin for XBMC. First, lets configure the ability to download subtitles at the touch of a finger from multiple services. Start by clicking on Programs -> Get More -> Subtitles -> XBMC Subtitles -> Install



Now you want to configure the subtitles. Pick your primary, secondary, and tertiary languages from the list. Set all 3 languages the same if you can only read one language:



Under Services, check Sublight.si and any extra subtitle services that may apply to you. In the advanced options section, you may want to check the option "Search next available service if no results are found" so that it will look through other subtitle services.

Hit OK and then escape a few times until you are back at the main XBMC Media Center screen. Now go to System -> Skin -> Add-On (Shortcuts) and scroll down to Video OSD at the bottom. Click on Subtitle Add-On.



This will bring up the next window that allows you to enable the XBMC Subtitles add-on by selecting it.



You will now have an on-screen display available to download subtitles if you would like from any movie or TV show that you would like. I will touch more on this again later.

While we're in the settings, let's set up the weather. Back out to the Settings menu and click on Weather.



The weather setup is pretty generous with how you can set it up. Click on the first location that you want to change and type an area code, a city/state, or a city/country combination and you should get a screen like the one below:



If you get multiple listings, select the appropriate one (e.g. you may have an airport listing as well) and then exit out of the weather one when you are satisfied with that. Go back to the main XBMC and check that the weather option works and is reporting correctly and looks like this:



If for some reason your regional settings for temperature are not correct, or you want to just change between Fahrenheit and Celsius all you need to do is go from the XBMC main menu to System -> Appearance -> International.



On this screen you will want to change your region, for example UK (24h) and UK (12h) will both give you Celsius while only changing the format of the clock from the USA regional format.

Next, for Android users there is a free application on the market called Official XBMC Remote that can be set up to control XBMC remotely (http or LAN). If you'd like you can go ahead and download the application on your phone while we configure the XBMC settings for the remote.

In XBMC go to Settings -> Network



These are the settings we want to change for the phone. We want to check "Allow control of XBMC via HTTP." You can leave the Port as 8080. Username can either stay as xbmc or be changed to something more secure. Password should also probably be changed to something more secure than being blank. You want to ensure that no one is able to just see your media that wanders by.

Now we need to find out the IP address of your computer. If you know what it is already (e.g. looking through your router) then you can skip this step. Otherwise, open terminal and type:

ifconfig

You'll see a long block of text, look for "inet addr:" followed by an ip address. Mine is 192.168.1.7 and that will be going into my phone in XBMC Remote. Now open up XBMC Remote. You should be greeted by a message that says:

No hosts detected

Click on "settings" or use the menu in order to add an XBMC host or IP address to your configuration."

So click settings, you'll be greeted by another error message asking you to press the menu key. Do so now, you'll now see an "Add Host" key. Tap that. Your setup should look similar the one below (things marked in red depend on you):

Name of this instance: HTPC
Host or IP address: 192.168.1.7
HTTP API port: 8080
Username: xbmc
Password: xbmcpassword
EventServer port:9777
WiFi only: checked
Access Point:
Mac Address: This should be filled in automatically when you type in your Host IP address
Socket read timeout in milliseconds: 5000
Wait after WOL in seconds: 40
WOL Port: 9

Now we can back out of the settings. But we still don't have any way to test the settings because we haven't added anything to the library yet. We'll get back to this one later too.

Before we get into adding actual movies or TV shows into XBMC, I want to cover how to add video Add-Ons. This is fairly straight forward and easy to do. from the main menu just select Videos -> Video Add-ons -> Get More...



This will give you access to a wide range of clips and videos from various networks including your playlists and favorites on YouTube once you have set your account up with the plugin.

Now to set up video libraries. We'll use TV shows for an example. First you want to click on Add Videos... click Browse and navigate to the first location of your TV shows. Now if you have multiple locations, click Add and then hit Browse again. If a hard drive doesn't show up, you may have to search for it in by selecting "Root filesystem" then going to "media." If all goes well, you should have something that looks like this:



Enter a name for the media source and hit OK. Mine will be TV Shows. Now this next part is optional, but you might want to choose a scraper that will go through all your TV shows, music, and movies and provide album covers, artwork, and posters.



There are three choices for scrapers: The TVDB for TV Shows, MTV for Music videos, and The MovieDB for movies. If you have a mix, you are able to add multiple scrapers.

Once you hit okay, you have the option of letting the scraper download information. It takes a little bit, but worth it. Once it is done downloading. click on the folder you just made, move your mouse to the left side of the screen to pull out the menu and if you'd like change the view to show more detail, or just icons.

Finally, let's say the scraper got the wrong show. It happens. Right click on the show, go to TV Show Information. Click "Refresh." Now select the show that corresponds to the original language and release date of the show that you want the actual poster for.

Now that we've got some files in our library, we can either select them with the keyboard and mouse or with the Android application that we downloaded earlier. In the bottom right corner of the XBMC application, click on the bubble that says something like "XBMC Pre-11.0 Git: Unknown" and it will give you a pop-up asking you which server you'd like to connect to. Select the HTPC one that we made earlier. Now to try watching a TV show. Select "Watch your TV Shows." If everything went well, you should see all of your album art on your phone now too. Select a show to try out and then hit play. Now, using your phone or the keyboard, if you would like to activate subtitles navigate to this button and click on it:



That will bring up a screen allowing you to pick from all the available subtitles for your language for that particular file. If you notice the file doesn't match the audio at all you can either go into the audio settings (two buttons to the right from the above picture) and adjust the delay of the subtitle file -or- download a new subtitle file if you noticed that you one got was too far broken to match at all (or completely wrong). The download screen will look like this though:



Once done downloading, the movie will resume playing and you are free to enjoy! This concludes the XBMC Media Center tutorial.

Sunday, May 22, 2011

Installing the Android SDK in Linux Mint 11

In a slight change of direction, I'm going to cover the installation of the Android SDK for those of you out there that are interested in developing and designing themes in Linux.

First thing we will want to do is prepare our computer by downloading and installing Eclipse. To do this, open up terminal and type the following command:

sudo apt-get install eclipse

Hit yes and let everything install. After that is done, select menu and search for and run Eclipse. The first screen you will be greeted by will look like the one below:



Just hit next to continue past the screen, or designate a folder for your workspace. If you'd like the folder to be hidden put a period in front of it. Now that we're in Eclipse, we need to set up the repository for the Android Development Tools (ADT) and download them. Click on Help and select Install New Software. From here, you want to click "Add..." and you should be at this screen now:



In the location section of this window, you want to put the following address:

https://dl-ssl.google.com/android/eclipse/

When you click OK the source will load (if for some reason this source isn't selected with "Work With", just change it) and you should see the Android Development Tools listed. Check all of them and click next through all of the menus and accept the licensing agreement.



Now let's put Eclipse on hold for a minute and go to the Android SDK Download page and get the .tgz file for Linux (i386). Once this is downloaded, open the terminal and go to the directory that it was downloaded to (possibly ~/Downloads) and if you are interested in checking the checksum against the one on the website, type:
md5sum android-sdk_r11-linux_x86.tgz

If all goes well, you'll be greeted by a checksum that matches the one on the website. Now to extract the .tgz file and move it to the home directory:

tar zxvf android-sdk_r11-linux_x86.tgz
mv android-sdk-linux_x86 ~/

If you'd like, you can delete the .tgz file now by typing rm android-sdk_r11-linux_x86.tgz. Now, return to Eclipse and go to Window -> Preferences. On this screen you want to select Android on the left side. For SDK Location, you will want it to be (depending on your version):

/home/username/android-sdk-linux_x86



So far, so good. You may or may not see this error pop up though:



No need to panic though, click Okay to get out of this and go back to the main Eclipse menu and then go to Window -> Android SDK and AVD Manager. On the left side, select Available Packages and then under "Android Repository" install the Android SDK Platform-tools, revision 4. Once that is installed, everything should be up and running and you'll have something that looks like this:



**There was an error in the bottom of the above screenshot that I got rid of by resetting Eclipse. I forgot to take a screenshot of it and wanted to mention that I had an error appear, but was still able to compile a "Hello World" script.

If you're interested in getting the Graphical Editing Framework installed, just go to Help -> Install New Software... Add the site listed below:

http://download.eclipse.org/tools/gef/updates/releases/

Select this repository and just choose the version of the Graphical Editing Framework that you want. It will install the same way as ADT did previously.

Finally, the Android Debug Bridge (ADB) can be located in the following directory and with the following commands:

cd ~/android-sdk-linux_x86/platform-tools
./adb

This will give you a laundry list of command tools for ADB.

**As an additional side note, I don't actually program for the Android OS. I did this writeup to help and encourage the Android community to program in the Linux environment. If for any reason this write up is incomplete, please let me know and I'll see what I can do to help complete it.