At this stage, you have: 1. Downloaded ADT Bundle 2. Created a workplace for development (during Eclipse startup) and 3. Updated SDK tool package. This section describes how to setup your test bed for your applications.
Setting up your Android device for real time application testing:
1. Phone/Tablet: Go to Settings > Developer options > Enable USB debugging.
2. Connect your device to computer via standard USB cable. Skip any warning or notification popped up on your device.
3. Check connected device status: Open Terminal (or cmd.exe in Windows). Navigate to- 'platform-tools' inside sdk folder:
Example:
Ubuntu: evinish@68D2ZR1:~/Documents/Android/adt-bundle-linux-x86_64-20130219/sdk/platform-tools$
Windows: C:\Android\adt_bundle_windows\sdk\platform-tools
4. Type: adb devices. You should see your device name listed in your output:
Example:
List of devices attached
emulator-5554 device
YT910166SL device
Your device is now ready to run your application. You may add the adb tool path in environment variable, so you don't have to navigate every time you launch command session.
Adding adb path to environment variable in Ubuntu
Open Terminal and follow these steps:
1. Check the path variable: echo $PATH
2. Add the adb path: export PATH=${PATH}:/home/evinish/Documents/Android/adt-bundle-linux-x86_64/sdk/platform-tools. This should be your path to adb.
3. To ensure the path is loaded each time system boots up, it should be added to .bashrc file:
echo -e '\nexport PATH=${PATH}:/home/evinish/Documents/Android/adt-bundle-linux-x86_64/sdk/platform-tools:/home/evinish/Documents/Android/adt-bundle-linux-x86_64/sdk/platform-tools' >> ~/.bashrc
Starting an AVD emulator
Although, you can test your application on a real device, it is not recommended (unless it is absolutely necessary). Android SDK provides emulator tools to emulate your app on your computer itself. Follow these instructions to set up an AVD emulator:
1. Open Eclipse. Go to Window > Android Virtual Device Manager.
2. Click 'New' and follow new Emulator creation wizard: Provide a meaningful AVD name. Select 'Device' and 'Target' machine.
3. Select CPU/ABI: ARM (armeabi-v7a)
4. Select Emulation option: Snapshot
5. Click OK.
6. Select newly created AVD and click 'Start'. You'd see AVD initialization sequence in Eclipse console.
Your new AVD would appear in a few minutes. The initial start-up may take upto 7 to 8 minutes!
If everything works fine, you'd see your AVD listed in the output of 'adb devices'
Known Issue #1 (Solved): Can't launch AVD emulator in Ubuntu
If you're using Ubuntu, there's a good chance your emulator won't start! Eclipse or AVD manager would not throw any error in such case. If so happens, check your console output. If the console output shows that preferred AVD is not available, then kill and re-start the ADB server.Open Terminal and type:
adb kill-server
adb start-server
Problem is still there?: goto tools directory in sdk bundle: evinish@68D2ZR1:~/Documents/Android/adt-bundle-linux-x86_64/sdk/tools$
It might be possible that Ubuntu is trying to run x86 or mips version of emulator. It's better to launch AVD from command line instead from Eclipse.
Can you run the emulator from command line?: ./emulator -avd <emulator_name>; emulator_name is the AVD name you created in eclipse. It might throw error like this:
Segmentation fault (Core dumped)
Now try to run the arm version of emulator directly from command line: ./emulator-arm -avd <emulator_name>. You would be able to launch the AVD! In order to launch AVD directly from Eclipse, here is a work around:
Seems like ADT can't load OpenGL driver on Ubuntu 12.04. The work around is to rename the file libOpenglRender.so
Solution: Goto the following path inside SDK bundle: tools/lib/ ----> Rename the file libOpenglRender.so to libOpenglRender.so.xxx so that Android can't find it!
Known Issue #2 (Solved): Can't delete AVD from Eclipse
If you can't delete AVD from AVD manager list, you can manually delete it.
Go to /home/.android folder (/.android is a hidden file). Navigate to /avd and delete AVD from this folder. Now goto eclipse and delete AVD. That's it!!
1. Phone/Tablet: Go to Settings > Developer options > Enable USB debugging.
2. Connect your device to computer via standard USB cable. Skip any warning or notification popped up on your device.
3. Check connected device status: Open Terminal (or cmd.exe in Windows). Navigate to- 'platform-tools' inside sdk folder:
Example:
Ubuntu: evinish@68D2ZR1:~/Documents/Android/adt-bundle-linux-x86_64-20130219/sdk/platform-tools$
Windows: C:\Android\adt_bundle_windows\sdk\platform-tools
4. Type: adb devices. You should see your device name listed in your output:
Example:
List of devices attached
emulator-5554 device
YT910166SL device
Your device is now ready to run your application. You may add the adb tool path in environment variable, so you don't have to navigate every time you launch command session.
Open Terminal and follow these steps:
1. Check the path variable: echo $PATH
2. Add the adb path: export PATH=${PATH}:/home/evinish/Documents/Android/adt-bundle-linux-x86_64/sdk/platform-tools. This should be your path to adb.
3. To ensure the path is loaded each time system boots up, it should be added to .bashrc file:
echo -e '\nexport PATH=${PATH}:/home/evinish/Documents/Android/adt-bundle-linux-x86_64/sdk/platform-tools:/home/evinish/Documents/Android/adt-bundle-linux-x86_64/sdk/platform-tools' >> ~/.bashrc
Starting an AVD emulator
Fig 1.7 Creating AVD |
1. Open Eclipse. Go to Window > Android Virtual Device Manager.
2. Click 'New' and follow new Emulator creation wizard: Provide a meaningful AVD name. Select 'Device' and 'Target' machine.
3. Select CPU/ABI: ARM (armeabi-v7a)
4. Select Emulation option: Snapshot
5. Click OK.
6. Select newly created AVD and click 'Start'. You'd see AVD initialization sequence in Eclipse console.
Fig 1.8 Android Virtual Device |
If everything works fine, you'd see your AVD listed in the output of 'adb devices'
Known Issue #1 (Solved): Can't launch AVD emulator in Ubuntu
If you're using Ubuntu, there's a good chance your emulator won't start! Eclipse or AVD manager would not throw any error in such case. If so happens, check your console output. If the console output shows that preferred AVD is not available, then kill and re-start the ADB server.Open Terminal and type:
adb kill-server
adb start-server
Problem is still there?: goto tools directory in sdk bundle: evinish@68D2ZR1:~/Documents/Android/adt-bundle-linux-x86_64/sdk/tools$
It might be possible that Ubuntu is trying to run x86 or mips version of emulator. It's better to launch AVD from command line instead from Eclipse.
Can you run the emulator from command line?: ./emulator -avd <emulator_name>; emulator_name is the AVD name you created in eclipse. It might throw error like this:
Segmentation fault (Core dumped)
Now try to run the arm version of emulator directly from command line: ./emulator-arm -avd <emulator_name>. You would be able to launch the AVD! In order to launch AVD directly from Eclipse, here is a work around:
Seems like ADT can't load OpenGL driver on Ubuntu 12.04. The work around is to rename the file libOpenglRender.so
Solution: Goto the following path inside SDK bundle: tools/lib/ ----> Rename the file libOpenglRender.so to libOpenglRender.so.xxx so that Android can't find it!
Known Issue #2 (Solved): Can't delete AVD from Eclipse
If you can't delete AVD from AVD manager list, you can manually delete it.
Go to /home/.android folder (/.android is a hidden file). Navigate to /avd and delete AVD from this folder. Now goto eclipse and delete AVD. That's it!!