Skip to content
tlam edited this page Mar 25, 2012 · 24 revisions

Pre-requisites

  • JAVA JDK: sudo apt-get install openjdk-6-jdk

Setup

  1. Unpack the android sdk at

     /home/tlam/android-sdk-linux_x86
    
  2. Add the android tools to your PATH

     if [ -d /home/tlam/android-sdk-linux_x86/tools ] ; then
         PATH=/home/tlam/android-sdk-linux_x86/tools:"${PATH}"
     fi
    
  3. Update android from the terminal, this should update your android targets:

     android update sdk --no-ui
    
  4. The above operation takes a while to run, alternatively, open the android GUI by running android at the terminal

  5. Select Available packages on the left panel and select the latest android SDK

  6. Add the platform-tools to your PATH

     if [ -d /home/tlam/android-sdk-linux_x86/platform-tools ] ; then
         PATH=/home/tlam/android-sdk-linux_x86/platform-tools:"${PATH}"
     fi
    
  7. List all your android targets:

     android list targets
    
  8. Create a new AVD, from the android GUI, select Virtual Devices from the left panel and click on New...

  9. Build command from the project folder:

     ant debug install
     ant release install
    
  10. Run the emulator in one shell:

     emulator -avd linux_avd
    
  11. From a new shell, install the apk:

     adb install HelloAndroid/bin/HelloAndroid-debug.apk
    
  12. Remounting the adb:

     adb remount
    
  13. From there, it should be possible to make changes to your app and after running ant install, the app should be reloaded in the emulator.

Note: After launching the emulator, wait till the android screen shows up.

Debugging from the shell

adb logcat

Updating an existing Android project and generate build.xml with ant

android update project --name <project_name> --target <target_ID> --path <path_to_your_project>

Creating a new Android project

No Eclipse

Integrating pmb in ant to detect unused code

  1. Download the latest pmd binaries

  2. Unzip to anywhere in your file system, for instance /home/user/pmd-4.2.5

  3. In your build.xml file, add the following near the end:

     <!-- Integrating pmd to detect unused code-->
     <path id="pmd.classpath">
         <pathelement location="${build}"/>
         <fileset dir="/home/user/pmd-4.2.5/lib/">
             <include name="*.jar"/>
         </fileset>
     </path>
     <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="pmd.classpath"/>
     <target name="pmd">
         <pmd rulesetfiles="basic,imports,unusedcode">
             <formatter type="html" toFile="pmd_report.html" toConsole="true"/>
             <fileset dir="src/">
                 <include name="**/*.java"/>
             </fileset>
         </pmd>  
     </target>
    
  4. Run the following command to generate a report of the pmd for unused code:

     ant pmd
    
  5. You should be able to view the html report pmd_report.html in the base folder of your android project.

  6. Here is a list of shortened rulesetfiles, strip out the .xml.

Taking screenshot of your app

Use ddms

Allowing an app to browse folder on Nexus S

  1. Go to Manage Apps
  2. Click on the app
  3. Click on Move to USB storage

You should not be able to browse the root folder that you seen when you connect your Nexus S to your computer.

Clone this wiki locally