{"revision": {"id": "f3a45634-2f95-11f1-89b6-e86a64d24d78", "node_id": "f3a3100e-2f95-11f1-a963-e86a64d24d78", "user_id": "edc3f576-2f95-11f1-900f-e86a64d24d78", "author": "foxhop", "data": "Android programming on Linux\r\n################################\r\n\r\n.. contents::\r\n\r\nSetup your development environment\r\n===========================================\r\n\r\n* install the Java Development Kit (JDK)\r\n\r\n  .. code-block:: bash\r\n\r\n   # On Redhat or Fedora run the following\r\n\r\n   yum install java-1.7.0-openjdk\r\n   yum install java-1.7.0-openjdk-devel\r\n\r\n\r\n* install the android sdk::\r\n\r\n   http://developer.android.com/sdk/index.html\r\n\r\n* adjust your path environment variable\r\n  \r\n  .. code-block:: bash\r\n    \r\n   # echo 'export PATH=$PATH:/home/fox/android/tools:/home/fox/android/platform-tools' >> ~/.bashrc\r\n   echo 'export PATH=$PATH:/path/to/android/tools' >> ~/.bashrc\r\n\r\n* optionally install eclipse\r\n* create an ADV (android virtual device) emulator\r\n\r\n**Tip:** Add the platform-tools/ as well as the tools/ directory to your PATH environment variable.\r\n\r\n\r\n\r\nCreate an android project on the cli\r\n=========================================\r\n\r\nreference: http://developer.android.com/guide/developing/projects/projects-cmdline.html\r\n\r\nThe following cli command will create an android project skeleton named HelloWorld in your home directory.\r\n\r\n.. code-block:: bash\r\n\r\n android create project \\\r\n    --package com.example.helloworld \\\r\n    --activity HelloWorld \\\r\n    --target 3 \\\r\n    --path ~/HelloWorld\r\n\r\ntarget\r\n  The \"build target\" for your application. \r\n\r\n  This corresponds to an Android platform library (including any add-ons, such as Google APIs) that you would like to build your project against. \r\n\r\n  To see a list of available targets and their corresponding IDs, **execute: android list targets.**\r\n\r\nname \r\n  The name for your project. \r\n\r\n  This is optional. If provided, this name will be used for your .apk filename when you build your application.\r\n\r\npath \r\n  The location of your project directory. \r\n\r\n  If the directory does not exist, it will be created for you.\r\n\r\nactivity \r\n  The name for your default Activity class. \r\n\r\n  This class file will be created for you inside <path_to_your_project>/src/<your_package_namespace_path>/ .\r\n\r\n  This will also be used for your .apk filename unless you provide a name.\r\n\r\npackage \r\n  the package namespace for your project\r\n \r\n  This will follow the Java programming language standards.\r\n\r\nProgramming the HelloWorld project\r\n=========================================\r\n\r\nmodify your source code...\r\n\r\n\r\n\r\nBuilding and running from the command line\r\n-------------------------------------------------\r\n\r\nReference: http://developer.android.com/guide/developing/building/building-cmdline.html\r\n\r\nThe Ant script compiles and builds your project into a .apk file which may be installed on an emulator or device.  \r\n\r\nAnt provides the following two build modes:\r\n\r\n* Test or Debug (Development)\r\n* Release (Production)\r\n\r\nRegardless of the build mode chosen the application must be signed before it can be installed on an emulator or device.\r\n\r\nIn development (debug mode) the SDK will automatically sign your project with a development key.  An application signed with a development key cannot be distributed.\r\n\r\nIn production (release mode) the SDK will not sign the .apk file, you will need to do this manually using the Keytool and Jarsigner.\r\n\r\n\r\n\r\nBuilding in debug mode (development)\r\n--------------------------------------------\r\n\r\n#. Navigate to root of the project\r\n#. Compile the project using Ant.\r\n\r\n   .. code-block:: bash\r\n\r\n      ant debug\r\n\r\nInstall debug application to emulator\r\n---------------------------------------------\r\n\r\n#. Start your AVD (android Virtual Device) emulator.\r\n#. Install your application using the adb script which exists in the platform-tools/ directory of the SDK. \r\n\r\n  .. code-block:: bash\r\n  \r\n    adb install ~/HelloWorld/bin/HelloWorld-debug.apk\r\n\r\n  You might need to specify the device serial which is found on the top of the virtual device titlebar.\r\n\r\n  .. code-block:: bash\r\n   \r\n    adb -s emulator-5554 install ~/HelloWorld/bin/HelloWorld-debug.apk\r\n\r\n  A top secret command for both building in debug mode and deploying to a running emulator use the following command:\r\n\r\n  .. code-block:: bash\r\n  \r\n   ant install \r\n\r\n\r\nHow to update Android SDK\r\n=========================================\r\n\r\nPeriodically you may want to update your development environment, here's how:\r\n\r\n* open a Terminal (ctrl+alt+t)\r\n* type 'android' and press enter\r\n* click the 'Installed packages' tab\r\n* click the 'Update All...' button\r\n\r\nInstalling Scala\r\n====================\r\n\r\nNot directly related to Android development, but I plan to learn Scala (expand my use of functional langs) while building android apps. \r\n\r\n.. code-block:: bash\r\n\r\n # download & unzip\r\n wget http://www.scala-lang.org/files/archive/scala-2.10.3.tgz\r\n tar -xzvf scala-2.10.3.tgz\r\n \r\n # install\r\n sudo mv scala-2.10.3 /usr/share/scala\r\n sudo ln -s /usr/share/scala/bin/scala /usr/bin/scala\r\n sudo ln -s /usr/share/scala/bin/scalac /usr/bin/scalac\r\n sudo ln -s /usr/share/scala/bin/fsc /usr/bin/fsc\r\n sudo ln -s /usr/share/scala/bin/scaladoc /usr/bin/scaladoc\r\n sudo ln -s /usr/share/scala/bin/scalap /usr/bin/scalap\r\n\r\nmight need sbt (scala build tools)", "source_format": "rst", "revision_number": 28, "created": 1392033096000}}