Project

General

Profile

How to compile and run the example code » History » Revision 19

Revision 18 (Distorted Admin, 06/03/2016 09:45 AM) → Revision 19/28 (Distorted Admin, 06/03/2016 09:45 AM)

h1. How to compile and run the example code

%{color:black}This %{color:blue}This tutorial explains how to turn the 'library' and 'examples' code into an application you can run on your Android phone.%

We are going to assume you are fairly familiar with Android development.
I personally use Android Studio; you can use Eclipse or even command line for your development but setting up the project will be different.%

# Download and install *Android Studio*: https://developer.android.com/studio/index.html
# Start it up and click on *Menu->File->New->New Project* to create a new, empty Project.
## In the *'New Project'* window set:
### Application Name: *Distorted Examples*
### Company Domain: *distorted.org*
### Package Name: click 'edit' and change the default to *org.distorted.examples*
## In the *'Target Android Devices'* window, make sure *Phone and Tablet* is checked. Everything else can be unchecked.
## In the *'Add an Activity to Mobile'* select *Add No Activity*.
## Click *Finish* and an empty project will be created for you.

Now we will need to download the sources and add both *'library'* and *'examples'* as new modules to the empty Project we've just created.
At the time I am writing this, *Android Studio 2.1.1* does not seem to support adding new modules directly from a Git repository; that's why we will have to do this in two steps.

# Download (git clone) the sources to a local directory:
## *Menu->VCS->Checkout from Version Control->Git*
## In the *'Clone Repository'* window, set *'Git Repository URL'* to *'http://distorted.org/git/distorted-library.git'*; you can leave the *'Parent Directory'* and *'Directory Name'* as they are.
## It will ask you if you want to open the new project file - don't do it.
## Repeat the above two steps again, this time setting the Git URL to *'http://distorted.org/git/distorted-examples.git'*
# Add the two newly created directories as modules to your Project:
## *Menu->File->New->Import Module...*
## Set source directory to wherever the cloned *'distorted-library'* is and click *'Finish'*.
## At this moment it may complain about missing Android SDK platforms and prompt you to *'Add root'* of the new VCS. Do both. Once you do it, you should see a new module called *'distorted-library'* in your Project's module list, right next to the automatically created *'app'* module.
## Repeat the above, this time giving it the location where *'distorted-examples'* got downloaded to. New module *'distorted-examples'* will appear.
## Now you can (and should!) remove the empty *'app'* module:
### *Menu->File->Project Structure...*
### Click on the *'app'* module in the left
### Click on the *red minus sign* to remove it
### Go to your Project directory and remove the *'app'* directory from it.

Now we should have the Project ready and Gradle successfully building it. Let's now try and run it then.

Because the Library uses *Open GL ES 2.1*, which is - at the time I am writing this - not supported on the Emulators, the only way is to test it on a real phone.

# Connect your phone to your computer via a USB cable. It needs to support OpenGL ES 2.1 - any fairly recent Android phone should.
# Make sure it is in Developer mode and USB Debugging is on.
# *Menu->Run->Run 'distorted-examples'*
# In the *'Select Deployment Target'* window select your phone and click *'Ok'*
# The *'Distorted Examples'* app will get installed on your phone.

Next: [[About the Distorted Examples App]]