Create Project

After downloading the Android client library into your project root we will use the Android Studio for creating new Android application project that include the library and refer to its classes.

This description is based on dialogs presented by Android plugin in InteliJ IDEA. If you need more information about using the Android Stodio or that you are usingother IDE you may want to check this link: http://developer.android.com/sdk/installing/create-project.html

 

Creating the basic project

  1. We assume that the root of your project is: c:\projects\sosa . * "sosa" stand for State Oriented Sharing App
  2. We assume that you previously unpacked the "cg" library into c:\projects\cg 
  3. Open Android Studio (on InteliJ with Android plugin setup)
  4. Create New Project -> android -> Application Module
  5. Click Next
  6. Set Application name: sosa
  7. Package name: com.example.sosa
  8. Activity name: MainActivity and check the "create hello world" activity
  9. Click Next
  10. Project name: sosa
  11. Project location: c:\sosa
  12. Project SDK:  Use android API 19 or above
  13.  Target device Emulator
  14.  Finish

  

Adding Dependency in  CG library

 Adding dependency in the CG library requires two steps. First adding the library as a module in your project. Then adding depandency in jar file provided with the library.

  1. Open the "Project Structure" dialog
  2. Click the + (plus) button for adding new module
  3. Select Android ->  Library module
  4. Click Next
  5. Module name: cg
  6. Content root: C:\projects\cg
  7. Module file location: C:\projects\cg
  8. Package name: rhz.cg
  9. Click Finish
  10. Select the "sosa" module from list of modules -> Click "Dependencies" tab
  11. Click the + (plus) button and select "Module Dependency..." option
  12. Select the "cg" module and click OK
  13. Click the "Apply" button below to save the settings.
  14. On the same dialog box Click the + (plus) button and select "Jars or Directories"
  15. Browse to c:\projects\cg\libs and select rhz_cg_android.jar 
  16. Click OK to apply changes 

 * If you are replacing dependencies for whatever reason, while your project is already constructed perform "Rebuild Project" to make sure that any old cache is cleaned. 

 

Adding external dependancies

Content Glass code may depand on external libraries and APIs. We collect these  libraries under "cg_depend" directory and you should add the dependancies to your project from these resources. Make sure not to conflict with similar libraries on your project. In the case of conflict select the newer version. 

 

Adding support V4 jar

  1. Open the "Project Structure" dialog
  2. Select the "sosa" module
  3. Click "Dependencies" tab
  4. Click the plus button and select "Jars or directories"
  5. Browse to C:\projects\cg_depand\support\v4\android-support-v4.jar
  6. Add the jar to dependancies list 

Agging Google Services

This is required only when you app use Content Glass resources that require the Google services. Note that adding the Google services will also require setting the developer key in the manifest file. The key is dedicated to your Google developers account. 

  1. Open the "Project Structure" dialog
  2. Click the plus button for adding new module
  3. Select Android library module type
  4. Browse to C:\projects\cg_depand\google-play-services_lib
  5. And create the module
  6. The modules "google-play-services_lib" has been created

Now we will add the dependancy in this library

  1. Open the "Project Structure" dialog
  2. Select the "sosa" module
  3. Click "Dependencies" tab
  4. Click the plus button and select "Module dependency..."
  5. Select "google-play-services_lib" and add to dependencies list of "sosa" module

* Remember that when you are using the google services module you will need to set meta data tages in the manifest with your developer keys.  It will look like this:

<!-- Google Play service meta data--> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/> <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="YOUR_KEY"/>

If you are not familiar with setting up Google services account for using Google services API please check this link: https://developers.google.com/console/help/new