Android: preparando una release

Antes de distribuir tu aplicación Android a usuarios de la red, necesitas prepararla para release. El proceso de preparación es una tarea requerida por todos los desarrolladores de apps Android y es el primer paso en el proceso de publicación (ver figura 1)

Cuando preparas tu aplicación para release, debes configurar, construir y probar un versión release de tu aplicación. Las tareas de configuración son simples, incluyendo un limpiado básico del código y modificaciones del código que ayudan a optimizar tu aplicación.

El proceso de compilación es similar al proceso de compilación cuando estás desarrollando y puede ser hecho utilizando las herramientas del JDK y del Android SDK.

Las tareas de pruebas sirven como un chequeo final, asegurandote que tu aplicación realiza lo esperado en condiciones reales.

Cuando has acabado de preparar tu aplicación para release entonces tienes un .apk firmado , que puedes distribuir directamente a usuarios o distribuit a través de un mercado de aplicaciones como Google Play.

En este tuto resumimos las principales tareas que necesitas realizar para preparar tu aplicación para release. Las tareas que son descritas en este documento se aplican a todas las aplicaciones Android independientemente de como ellas son distribuidas al usuario. Si estás sacando tu aplicación a través de Google Play, debes leer  Publishing on Google Play para estar seguros de que cumple todos los requerimientos de Google Play.

Nota: Como una buena práctica, tu aplicación debe cumplir todos los criterios de funcionalidad, rendimiento, y estabilidad antes de realizar las tareas subrayadas en este documento.

Shows how the preparation process fits into the development process

Figure 1. Preparing for release is a required development task and is the first step in the publishing process.

Introduction

Para sacar una release de tu aplicación a los usuarios necesitas crear un paquete release-ready que los usuarios puedan instalar y ejecutar en sus dispositivos Android. El paquete release-ready contiene los mismos componentes que el fichero .apk de la fase de debug- codigo fuente compilado, recursos, fichero de manifest, etc – y es compilado por las mismas herramientas de build. Sin embargo, a diferencia del fichero .apk, el .apk release ready está firmado con tu propio certificado y es optimizado con la herramienta zipalign.

Shows the five tasks you perform to prepare your app for release

Figure 2. Se realizan cinco tareas básicas para preparar tu aplicación para release.

Las tareas de firmado y optimización van generalmente juntas si estas compilando tu aplicación con Eclipse y el plugin ADT o con el script de Ant (incluido con el Android SDK). Por ejemplo, puedes utilizar el Eclipse Export Wizard para compilar, firmar, y optimizar tu aplicación todo de una vez. Puedes también configurar el script de Ant para hacer lo mismo si compilas desde la linea de comando.

Para preparar tu aplicación para una release tienes que realizar 5 tareas principales (ver figura 2).Cada una de estas tareas pueden incluir una o más subtareas más pequeñas dependiendo de cómo estas publicando tu app. Por ejemplo, si se está publicando tu app a través de Google Play puedes querer añadir reglas especiales de filtrado a tu manifest mientras preparas la release. De forma similar, conocer las reglas de publicación de Google Play puede que tengas que hacer capturas de pantalla y algún texto promocional en el proceso de recogida de materiales para la release

Generalmente las tareas listadas en la figura 2 después de que has depurado y testeado  concienzudamente tu app. El Android SDK contiene varias herramientas que te ayudan a probar y depurar las Android apps. Para más info ver the Debugging and Testing sections in the Dev Guide.

Recopilando material y recursos

Para empezar a preparar tu aplicación para una release necesitas recopilar varios elementos de soporte. Como mínimo esto incluye unas claves criptográficas para firmar tu app y un icono de aplicación. Podrías también incluir un licencia de usuario final.

Claves criptográficas

El sistema Android requiere que todas las aplicaciones instaladas sean firmadas digitalmente con un certificado cuyo propietario sea el programador de la app (es decir, un certificado que contiene la clave privada del programador). El sistema Android utiliza el certificado como un medio de identificar al autor de una app y establecer relaciones de confianza entre las apps. El certificado que uses para firmar no necesita estar firmado por una autoridad certificadora , el sistema Android te permite firmar tus apps con certificados auto-firmados. Par aprender más sobre requisitos de certificados ver Obtain a suitable private key.

Importante: Tu app debe estar firmada con una clave criptográfica cuyo periodo de validez finaliza el 22 de Octubre de 2033

Podrías además tener que conseguir otras release keys en el caso de que tu app acceda a un servicio o utilice una third-party library las cuales requiere que utilices un key basada en tu provate key. Por ejemplo , si tu app utiliza la clase MapView , la cual es parte de la Google Maps external library, necesitas registrsr tu app con el servicio de Google Maps y obtener una Maps API key. Para más info sobre esto: Obtaining a Maps API key.

Icono de aplicación

Asegurate que tienes un icono de app y que este cumple con las recomendaciones de icon guidelines.El icono de tu app ayuda a los usuarios a identificar tu app en su pantalla de Home y en la Launcher window. También aparecerá en Manage Applications, My Downloads, y en más sitios.Además , publicar en servicios tales como Google Play muestra  tu icono a los usuarios.

Nota: Si estas publicando tu app en Google Paly, necesitarás crear una versión de alta resolución de tu icono. Ver Graphic Assets for your Application para más info.

Licencia de Usuario final (End-user License Agreement)

Considera redactar una End User License Agreement (EULA) para tu app. Una EULA puede ayudarte a proteger tu persona , organización , y propiedad intelectual , y recomendamos que tengas una para tu app.

Otros materiales

Podrías también preparar material de marketing y promocional para publicitar tu app. Por ejemplo , si estás publicnado tu app en Google Play necesitrás preparar algún texto promocional y necesitarás crear pantallazos de tu app. Para más info: Graphic Assets for your Application

Configurar tu app para subir una release

Después de recopilar todo el material de apoyo , puedes empezar a configurar tu app para subir una release. Esta sección te proporciona un resumen de los cambios de configuración que recomendamos que hagas a tu código fuente, ficheros de recursos, y al archivo manifest antes de subir una release de tu app. Aunque la mayoría de los cambios de configuración listados en esta sección son opcionales, consideralos buenas práticas de programación y animamos a que las implementes. En algunos casos, puede que hayas aplicado estos cambios de configuración como parte de tu proceso de desarrollo.

Elegir un buen nombre de paquete

Asegurate que elijes un nombre de paquete que se ajuste a lo que va a ser la vida de tu app. No puedes cambiar el nombre del paquete despuñes de distribuir tu app a los usuarios. Puedes configurar este valor en el manifest de tu app. Para más info ver package attribute documentation.

Desactiva logging and debugging

Asegurate que desactivas las opciones de logging y debugging antes de compilar tu app para release. Puedes desactivar el logging eliminando las llamadas a los métodos de Log en tu código fuente. Puedes desabilitar el debugging borrando el atributo  android:debuggable del <application> tag en el fichero manifest. Además, elimina cualquier fichero de log o ficheros estáticos de pruebas que hayas creado dentro de tu proyecto.

Además , debrías eliminar todas las Debug tracing calls que has añadido a tu código, tales como startMethodTracing() and stopMethodTracing() method calls.

Limpia los directorios de tu proyecto

Limpia tu proyecto y asegurate que está conforme con la estructura de directorio descrita en  Android Projects (es la que te crea el Eclipse cuando haces New Android Project). Dejar ficheros huérfanos en tu proyecto puede hacer que no compile tu app y se provoquen comportamientos inesperados. Como mínimo debes hacer las siguientes tareas de limpieza:

  • Revisa los contenidos de tus carpetas jni/lib/, and src/ directories. The jni/ directory should contain only source files associated with the Android NDK, such as .c.cpp.h, and.mk files. The lib/ directory should contain only third-party library files or private library files, including prebuilt shared and static libraries (for example, .so files). The src/directory should contain only the source files for your application (.java and .aidl files). The src/ directory should not contain any .jar files.
  • Comprueba que no tengas ficheros privados o ficheros propietarios que tu aplicación no utilice y eliminalos. For example, look in your project’s res/ directory for old drawable files, layout files, and values files that you are no longer using and delete them.
  • Check your lib/ directory for test libraries and remove them if they are no longer being used by your application.
  • Review the contents of your assets/ directory and your res/raw/ directory for raw asset files and static files that you need to update or remove prior to release.

Revisión y actualización de la configuración de tu Manifest

Verifica que los siguientes elementos del manifest están correctamente configurados:

  • <uses-permission> element . You should specify only those permissions that are relevant and required for your application.
  • android:icon and android:label attributes You must specify values for these attributes, which are located in the <application> element.
  • android:versionCode and android:versionName attributes.We recommend that you specify values for these attributes, which are located in the <manifest> element. For more information see Versioning your Application.

There are several additional manifest elements that you can set if you are releasing your application on Google Play. For example, the android:minSdkVersion andandroid:targetSdkVersion attributes, which are located in the <uses-sdk> element. For more information about these and other Google Play settings, see Filters on Google Play.

Ten en cuenta cuestiones de compatibilidad

Android provides several tools and techniques to make your application compatible with a wide range of devices. To make your application available to the largest number of users, consider doing the following:

  • Add support for multiple screen configurations.Make sure you meet the best practices for supporting multiple screens. By supporting multiple screen configurations you can create an application that functions properly and looks good on any of the screen sizes supported by Android.
  • Optimize your application for Android 3.0 devices.If your application is designed for devices older than Android 3.0, make it compatible with Android 3.0 devices by following the guidelines and best practices described in Optimizing Apps for Android 3.0 .
  • Consider using the Support Library.If your application is designed for devices running Android 3.x, make your application compatible with older versions of Android by adding the Support Library to your application project. The Support Library provides static support libraries that you can add to your Android application, which enables you to use APIs that are either not available on older platform versions or use utility APIs that are not part of the framework APIs.

Actualiaza URLs de servidores y servicios

If your application accesses remote servers or services, make sure you are using the production URL or path for the server or service and not a test URL or path.

Licencia de Implementación (si estás publicando en Google Play)

Si estas publicando una aplicación pagada a trvés de Google Play, considera añadir soporte para Google Play Licensing. Con esta licencia puedes controlar el acceso a tu app basandose en si el usuario actual la hax comprado. Utilizar Google Play Licensing es opcional incluso si estás publicando a través de Google Play.For more information about Google Play Licensing Service and how to use it in your application, see Application Licensing.

Compilar tu app para release

After you finish configuring your application you can build it into a release-ready .apk fle that is signed and optimized. The JDK includes the tools for signing the .apk file (Keytool and Jarsigner); the Android SDK includes the tools for compiling and optimizing the .apk file. If you are using Eclipse with the ADT plugin or you are using the Ant build script from the command line, you can automate the entire build process.

Building with Eclipse

You can use the Eclipse Export Wizard to build a release-ready .apk file that is signed with your private key and optimized. To learn how to run the Export Wizard, see Compile and sign with Eclipse ADT. The Export Wizard compiles your application for release, signs your application with your private key, and optimizes your application with the zipalign tool. The Export Wizard should run successfully if you have run or debugged your application from Eclipse and you have no errors in your application (see Building and Running from Eclipse with ADT for more information.

The Export Wizard assumes that you have a certificate and private key suitable for signing your application. If you do not have a suitable certificate and private key, the Export Wizard will help you generate one (see Signing Your Applications for more information about the signing process and signing guidelines.

Building with Ant

You can use the Ant build script (included in the Android SDK) to build a release-ready .apk file that is signed with your private key and optimized. To learn how to do this, see Building in Release Mode. This build method assumes you have a certificate and private key suitable for signing your application. If you do not have a suitable certificate and private key, the Export Wizard will help you generate one (see Signing Your Applications for more information about the signing process and signing guidelines.

Preparing External Servers and Resources

If your application relies on a remote server, make sure the server is secure and that it is configured for production use. This is particularly important if you are implementing in-app billing in your application and you are performing the signature verification step on a remote server.

Also, if your application fetches content from a remote server or a real-time service (such as a content feed), be sure the content you are providing is up to date and production-ready.

Testing Your Application for Release

Testing the release version of your application helps ensure that your application runs properly under realistic device and network conditions. Ideally, you should test your application on at least one handset-sized device and one tablet-sized device to verify that your user interface elements are sized correctly and that your application’s performance and battery efficiency are acceptable.

As a starting point for testing, see What to Test. This article provides a summary of common Android situations that you should consider when you are testing. When you are done testing and you are satisfied that the release version of your application behaves correctly, you can release your application to users. For more information, see Releasing Your Application to Users. If you are publishing your application on Google Play, see Publishing on Google Play.