Libraries in Android. Part I

Libraries are one of the best mechanisms to get reusable code. Knowing how to create libraries is a basic step when we have any common functionality for several apps or we want to share it with other developers. The two simplest ways to share code in Android are:

  • Android library projects. We can get any standard Android project to act as a library by activating this property. The library can be imported into any project that needs to use it. The library project is distributed with its source code and resources. To read a complete description of library projects, see the official documentation here.
  • JAR files. A .jar file contains the compiled classes. The source code can be included in it or not. We can’t share Android resources using a .jar file, just code classes.

The decision to choose between one of them depends on our requirements. Do we want to share xml resources? Do we mind sharing the source code?
Library types

How can we share a project with resources but not to share the source code? As the Android documentation states,

A library cannot be distributed as a binary file (such as a JAR file). This will be added in a future version of the SDK Tools.

I propose two solutions (surely there are more of them):

  • Create a Library Project to include the resources, but include the source code using a JAR file.
  • Create the resources programmatically instead of using the XML files and export it to a JAR file.

These proposed solutions will be shown in detail in the next posts about this topic:

Read More

Passbook: Type ID and certificate

Related posts about Passbook:


In order to create passes and allow them to be recognized by Passbook, they have to be signed with a valid certificate. The certificate is associated to a specific type of pass, so we need to create a Pass Type ID and a certificate for each kind of pass we want to support.

To create a Pass Type ID, log in into your developer account, navigate to your member center and to the Certificates, Identifiers & Profiles page. In the identifiers section, select the Pass Type IDs option. From this page the passbook Type IDs are listed and we can edit them, delete them or create a new one. Click on the plus icon button to create a new ID. Type a description and type the ID which has to start with the “pass.” string.

Register iOS Pass Type ID

Follow the next steps and the ID registration will be completed. The new ID should appear in the Pass Type IDs list.

To create the Pass Type ID Certificate, open the Production page from the Certificates section and click on the plus icon button to create a new one. Check the Pass Type ID Certificate option and click on the Continue button. In the next page we have to select the ID created before. Click on the Continue button.

iOS certificate of the Pass ID

Finally we have to upload our Certificate Signing Request file (.certSigningRequest). This request file can be obtained from the Keychain of a MacOS computer, but probably you already generated it when you created your app or created other certificates. Upload this request file, click on the Generate button and then we willl be able to download the certificate by clicking the Download button. The downloaded certificate is a .cer file.

Download Pass certificate

Read More