Adding the Android Licensing Library to an AndroidStudio Project

It appears that currently creating an external library is not all that easy. I wanted to add the Android Licensing Library and they advise creating a copy from it. I decided to just use a project library instead of messing around but have the sources in the repo. Here is what I did:

  • Download the licensing library with the SDK Manager
  • Copy it from the android SDK (the location is visible in AndroidStudio->Tools->Android->SDK Manager) to another location
  • Check in the library into your version control system
  • In your AndroidStudio project create a library project. Projects->New Module->Library ‘SomeName’ Package name = com.google.android.vendor.licensing
  • Now with your file system browser go into the ‘SomeName’->src->main->java directory and delete the package that was created
  • Check out the licensing library into a new empty directory somewhere and go into the src dir and copy the ‘com’ subfolder
  • Copy this tree to theĀ  ‘SomeName’->src->main->java directory (this makes sure the .svn references are now pointing to the correct repo location)
  • Now in your main project open gradle.build and make sure the new module is listed there (I had to add it)
    dependencies
    {
        compile project(':assetLib')
        compile project(':openGLISH')
        compile project(':mathLib')
        compile project(':ishlicensing')
        compile 'com.android.support:support-v4:18.0.0'
    }
  • Now you should be able to compile your project and check everything into svn. (note uncheck ‘Code Analysis’ if pressing the ‘Commit’ button doesn’t do anything).

 

Leave a Reply