#VS2015 – Some lessons learned working with #Android and #WindowsPhone Virtual Machines for development

Hola!

The development experience using Visual Studio 2015 creating apps for Android or Windows Phone is amazing. Until you get to a point where you need to work with Bluetooth, the you realize that the emulator does not support this feature and you need to find a workaround. So far the best alternative option I’ve found is this one

1. Download an image of Android from http://www.android-x86.org/

2. Install VirtualBox

3. Create a VM using the image downloaded in 1 point

4. Set the VM image to use a local USB device where you have Bluetooth dongle. In this case it is a BlueTooth 4.0 ASUS adapter

5. Done!

Now you can launch the emulator and have a fully working Android which supports Bluetooth and Bluetooth LE emulation. However, even if this works, the development experience is a bit poor. Personally I prefer to deploy the APK on my mobile and test the app in the phone. This also allows us to debug step by step and as a Developer in a very complete experience with Visual Studio 2015. For example, the following image shows the debugging options of Xamarin Android apps in Visual Studio. In addition to several VMs with Android, it is a plugged in Samsung device. This is so cool.

Going back to VirtualBox and VMs, the main problem I found is this one:

If you work with 10 Windows and Visual Studio 2015, if you install other virtual machines managers or software which changes your networks settings; it is likely that the Hyper-V configuration raises tons of exceptions.

Luck for us, our MSDN friends shared a great article which explains, plenty of the scenarios where the emulator does not work fine. I’ve been reviewing the network settings and I could not find the error.

Until I found it in the settings of Hyper-V. In the virtual adapter that is used for the VMs of Android and Windows Phone, the type of connection should be Internal network.

2 Click then could already prove the graphic aspects of my app in the emulator. I do BlueTooth tests directly in the physical device

I strongly recommend to give a look at the link to MSDN references. It covers many errors scenarios that certainly will save you many headaches!

Saludos @ Madrid

/El Bruno

References

– Android on X86 http://www.android-x86.org/

– Oracle Virtual Box https://www.virtualbox.org/

– ASUS BT 400 http://www.amazon.es/gp/product/B00CM83SC0

– MSDN Emulator Fails to Start https://msdn.microsoft.com/en-us/library/mt228282.aspx?f=255&MSPPError=-2147217396#NoStart

[Tags Visual Studio 2015, Xamarin, Android, Hyper-V, VM, English Post]

#VS2015 – Algunas lecciones aprendidas sobre la configuración de la #VM de #Android y #WindowsPhone

Hola!

La experiencia de desarrollo con Windows Phone o Android con Visual Studio 2015 es increíble. Hasta que quieres probar temas relacionados con Bluetooth, el emulador no lo soporta y hasta donde he visto lo más cercano que se puede hacer es

1. Descargar una imagen de Android desde http://www.android-x86.org/

2. Instalar VirtualBox

3. Crear una VM utilizando la imagen descargada en el punto 1

4. Configurar la imagen para que use un dispositivo USB local. En este caso es un adaptador BlueTooth 4.0 ASUS

5. Done !!!

Es lanzar el emulador y tener una versión de Android que soporta emulación de Bluetooth y Bluetooth LE. Si bien esto funciona, la experiencia de desarrollo es un poco pobre. Personalmente prefiero desplegar el APK en mi móvil y probarlo allí directamente. Esto además nos permite depurar paso a paso y como Developer es una experiencia muy completa. Por ejemplo, la siguiente imagen muestra las opciones de depuración de una app Xamarin Android, donde además de varias VMs con Android, está un device Samsung.

Volviendo a la prueba con las VMs y VirtualBox, el gran problema que encontré es el siguiente:

Si trabajas con Windows 10 y Visual Studio 2015, al instalar otros gestores de máquinas virtuales, es probable que la configuración de red de Hyper-V quede en un estado lamentable.

Los amigos de MSDN tienen un artículo que explica paso a paso las opciones a seguir cuando el emulador no funciona. En mi caso fue revisar, una y otra vez las network settings y no dar con el error.

Hasta que di con el mismo en las settings de Hyper-V. En el adaptador virtual que se utiliza para las VMs de Android y Windows Phone, el tipo de conexión debe ser Internal network.

2 Click después ya podía probar los aspectos gráficos de mi app en el emulador. Las pruebas de BlueTooth las hago directamente en el device físico

Así que para finalizar, recomiendo darle u vistazo al link de MSDN de referencias ya que cubre muchos escenarios de errores que seguramente te ahorraran varios dolores de cabeza !!!

Saludos @ Madrid

/El Bruno

References

– Android on X86 http://www.android-x86.org/

– Oracle Virtual Box https://www.virtualbox.org/

– ASUS BT 400 http://www.amazon.es/gp/product/B00CM83SC0

– MSDN Emulator Fails to Start https://msdn.microsoft.com/en-us/library/mt228282.aspx?f=255&MSPPError=-2147217396#NoStart

[Tags Visual Studio 2015, Xamarin, Android, Hyper-V, VM]

#VS2015 – Listing #BlueTooth LE Devices in #Android with #Xamarin

Hola!

Today I will begin with a series of posts based on my work with Xamarin and BlueTooth (LE) Low Energy devices. I’ve already written a couple of posts on how to work with Windows 10 Universal Apps and BlueTooth LE, in those examples I shared my experiences connecting a Windows 10 device to a heart rate sensor and display the HR value in an App. Today’s example is simpler: show all BLE Devices that can be detected by an Android device.

The first thing we will do is to create an Xamarin Android app.

Note: If you don’t know Xamarin, in the references section I have shared a link with resources to get started with Android.

The next step is to add a button and a multiline text in the main view. The app flow is easy: press the button, and then the BLE Devices found will be listed.

The next step is to identify the button and the text box. Also we need to creating a new instance of BlueToothLeScanner to list the BlueTooth Low Energy devices and subscribe to the ScanTimeOutElapsed() and DeviceDiscovered() events.

Important: From what I’ve seen, there are 2 modes of working with BlueTooth Devices. For normal devices, you must use the Adapter class, which is obtained from the BlueTooth system service, lines 30 to 32. In the case of BlueTooth LE, this is not a system service, simply have to create a new instance of BlueToothLeScanner and work with this object, lines 34 to 36.

Then in the DeviceDiscovered() event, we will show the new device in the box of text, line 45-29.

The same will do when the process of scanning-error, lines 39 to 43.

Finally, at the click of the button will begin the process of searching for BLE Devices.

The result of the app in operation is as follows

I’m not sure why the app raises so many times the same device. While that is not a problem, I have a couple of nights to take it forward 😉

You can download the code from here https://github.com/elbruno/Blog/tree/master/Xamarin/AndroidApp4

Saludos @ Madrid

/El Bruno

References

– El Bruno, posts on BlueTooth LE https://elbruno.com/category/BLE/

– Polar Heart Rate Sensor H7, http://www.polar.com/us-en/products/accessories/H7_heart_rate_sensor

– Xamarin, Hello Android http://developer.xamarin.com/guides/android/getting_started/hello,android/

– Xamarin Android.Bluetooth.LE.BluetoothLeScanner http://developer.xamarin.com/api/type/Android.Bluetooth.LE.BluetoothLeScanner/

[Tags Visual Studio 2015, Xamarin, Bluetooth, BLE, Android, English Post]

#VS2015 – Icon Generator for #Xamarin Android app

Hola!

All developers knows  that you must spend some time to ensure the usability in an App. A good app, with a poor user experience, is going to fail for sure. This topic is huge and those who knows have written tons of materials about it. Also, I’m quite lazy, so I won’t write about this. Caution!, being lazy is on of the top skills for in a Developer. This type of mentality, makes sure that we always look for the more simple, effective and flawless solution for a given problem.

For example, if we start to create Android Xamarin apps with Visual Studio 2015, you need to create a complete set of resources in various formats for the graphics. In example, in the following image you can see the different formats of icons suggested by Xamarin, that we should create in our apps..

Lucky for us there is a great Tool Android Asset Studio. This website allows us to generate a similar set of graphic resources from a text, ClipArt or an image. A live samples is the better way to explain this.

At this point, we get the chance to download a ZIP file with all the images created from our initial image.

We can add this resources to Visual Studio and that’s it !!!

Clipboard03

Saludos @ Madrid

/El Bruno

References

· Android Asset Studio http://romannurik.github.io/AndroidAssetStudio/

· Xamarin Android Deep Dive https://developer.xamarin.com/guides/android/getting_started/hello,android/hello,android_deepdive/

#VS2015 – Asistente para crear los iconos necesarios para una app #Android con #Xamarin

Hola!

Una lección que los desarrolladores aprendemos a la fuerza, es que en cualquier tipo de app, hay que dedicare tiempo para que la usabilidad de la misma sea un PLUS. Una buena idea, pero con una pobre experiencia de usuario, va a fracasar seguro. Esta historia es larga y los que saben han escrito mucho al respecto y como yo soy bastante vago, pues no escribiré al respecto. Ojo!, que ser vago es un gran Skill para un Developer. Este tipo de mentalidad, hace que busquemos la salida más simple, efectiva y sin errores frente a un problema.

Por ejemplo, si vemos que para crear apps Android con Xamarin y Visual Studio 2015, es aconsejable completar los recursos en varios formatos, lo mejor es buscar una herramienta que nos genere estos contenidos. Por ejemplo, en la siguiente imagen pueden ver los diferentes formatos de iconos que deberíamos crear para nuestras apps.

Por suerte en Android Asset Studio podemos encontrar una serie de generadores de iconos que nos ayudarán en tan ardua tarea. Podemos generar los mismos a partir de Texto, de un ClipArt o de una imagen. Veamos un ejemplo a partir de una imagen.

El resultado final es un Zip con varios formatos a partir de nuestra imagen inicial.

Ahora solo nos queda agregar estos recursos en Visual Studio y a seguir con el código !!!

Clipboard03

Saludos @ Madrid

/El Bruno

References

· Android Asset Studio http://romannurik.github.io/AndroidAssetStudio/

· Xamarin Android Deep Dive https://developer.xamarin.com/guides/android/getting_started/hello,android/hello,android_deepdive/

[#VS2013] Visual Studio 2013 + #SignalR + #Xamarin = true

Hello!

So holidays = true; so the posts from today will be short. In this one I’ll show the way we can add support for SignalR inside an Android app. Simpler is impossible.

Select the folder “components” of the Android project, deploy the contextual menu and select “Get More Components…” ”

image

Within Xamarin Component Store, we carry out a SignalR filter and here we have the component that you can use.

image

Note: The component is available for Android, iOS and Windows Phone Open-mouthed smile

Then select the option “Add to App” and ready, in a few seconds we will have our app so you can use SignalRwithin the same.

image

Not gonna go into details of the code of the app (remember I’m on vacation), however the example presented by the official website of Xamarin SignalR component, is more than self-explanatory.

image

If in addition you’ve used SignalR before, you’ll see that the portability that exists is great, the code is the same!

And voila we have support for Xamarin and SignalR in a few steps!

SignalR for Xamarin. http://components.xamarin.com/view/signalr

Saludos @ Home

El Bruno

image image image Google

[#XAMARIN] Updating #Android emulators to work with #VisualStudio and #Xamarin

Hello!

Xamarin Studio 3.0 is an amazing product. The main idea is all the programming is with C#, so if you know C# already have almost a 7% of done Winking smile. That’s because, the programing language is important, but is most important the platform you use to create apps.

Going back to Xamarin, I found myself with the following exception, building and running a demo:

Target device (emulator-5554) has an API level of 12, but this application has a minimum API level of 15 set.

The minimum API level can be changed in the project properties on the Android Manifest tab.

This error is given in our list of emulators for Android only we have available 2 virtual devices, in this case for API level 10 and 12.

image

So what we have to do is “installed” or download new emulators that support in this case Api Level 15. Now it the time to search and run the Android SDK Manager.

Windows search quickly leads us to the Android SDK directory

image

And within the same can already launch [SDK Manager.exe], which is the app who manages Android SDK resources we have installed locally. In the next image you can see as I have selected resources for API Level 19 and I’ve decided to download plus a couple of images also to work with them.

image

After a few minutes, will finish the download and installation. Now you can close the Android SDK Manager and return to Visual Studio.

image

From the IDE launched the Android Emulator Manager in the option ‘ Tools / / Android/Open / Android Emulator Manager… ”

image

And we will see that we… still have only emulators for API Level 10 and 12. So that now create a new AVD with the definitions that we need. For this click on Create and for example, to create one for a Nexus 7 with the following configurations.

image

Once defined the values, we can already see the result of the process of creating the AVD.

image

It also appears in the list of AVDs

image

And you can launch it from the Android Virtual Device Manager

image

And we can see the emulator running in a few seconds

image

Note:At first glance, emulators for Android leave a lot to be desired when compared to the Windows Phone.

Now already we can return to our Xamarin Android project and… when we select the device or emulator for testing, we have available that we created in previous steps.

image

And now yes, Welcome to Xamarin Forms!

Saludos @ Home

El Bruno

image image image Google

[#XAMARIN] Actualizando emuladores de #Android para #VisualStudio

Hola!

Xamarin Studio 3.0 es un gran producto. La base del mismo es que toda la programación es en C#, con lo que si conoces C# ya tienes un 7% ganado. Lo demás es lo de siempre, el programing language es importante, sin embargo lo importante es la plataforma sobre la que creas apps.

En el caso de Xamarin, cuando creas apps para Android te puedes encontrar con un error como el siguiente:

Target device (emulator-5554) has an API level of 12, but this application has a minimum API level of 15 set.

The minimum API level can be changed in the project properties on the Android Manifest tab.

Este error viene dado ya que en nuestro listado de emuladores de Android solo tenemos disponibles 2 virtual devices, en este caso para API level 10 y 12.

image

Asi que lo que tenemos que hacer es “instalar” o descargar nuevos emuladores que soporten en este caso Api Level 15. Ahora llega el momento de buscar y ejecutar Android SDK Manager.

La búsqueda de Windows nos lleva rápidamente al directorio de Android SDK

image

Y dentro del mismo ya podemos lanzar [SDK Manager.exe], que es la app que se encaga de gestionar los recursos de Android SDK que tenemos instalados localmente. En la siguiente imagen se puede ver como he seleccionado recursos para API Level 19 y he decidido descargar además un par de imágenes para poder trabajar con las mismas.

image

Al cabo de unos minutos, terminará la descarga e instalación. Ahora ya podemos cerrar Android SDK Manager y volver a Visual Studio.

image

Desde el IDE lanzamos el Android Emulator Manager en la opción “Tools // Android // Open Android Emulator Manager …”

image

Y veremos que … todavía tenemos sólo los emuladores para API Level 10 y 12. Asi que ahora toca crear un nuevo AVD con las definiciones que nosotros necesitamos. Para esto click en Create y por ejemplo, creamos uno para un Nexus 7 con las siguientes configuraciones.

image

Una vez definidos los valores, ya podremos ver el resultado del proceso de creación del AVD.

image

El mismo aparecerá además en la lista de AVDs

image

Y podremos lanzarlo desde el Android Virtual Device Manager

image

Y podremos ver el emulador funcionando en pocos segundos

image

Nota: A primera vista, los emuladores de Android dejan mucho que desear comparados con el de Windows Phone.

Ahora ya podemos volver a nuestro proyecto de Xamarin para Android y … cuando seleccionamos el device o emulador para probar, ya tenemos disponible el que creamos en pasos anteriores.

image

Y ahora si, Welcome to Xamarin Forms !!!

Saludos @ La Finca

El Bruno

image image image Google