Share via

Xamarin.Forms empty content page for compiled application on Android phone

Ruben van Niekerk 1 Reputation point
2021-07-29T13:57:11.513+00:00

The App runs perfectly on the emulator. The UI loads and messages display. When I compile an apk and install it on my phone the application is blank. It only shows a empty content page, no UI elements. The application is a uses Plugin.BLE and is loosely based on the tutorial on their GitHub page. https://github.com/xabre/xamarin-bluetooth-le.

Snipets of my code are shown bellow.
In App.xaml.cs

public partial class App : Application
{
public App()
{
InitializeComponent();
MainPage = new MainPage();
}

In View folder, MainPage.xaml.cs

using Plugin.BLE;
using Plugin.BLE.Abstractions.Contracts;
using Plugin.BLE.Abstractions.Exceptions;
using System;
using System.Collections.ObjectModel;
using Xamarin.Forms;
using BluetoothTUT.ViewModels;
using System.Collections.Generic;

namespace BluetoothTUT
{
    public partial class MainPage : ContentPage
    {
        IBluetoothLE ble;
        IAdapter adapter;
        ObservableCollection<IDevice> deviceList;
        IDevice device;


        public MainPage()
        {
            InitializeComponent();
            ble = CrossBluetoothLE.Current;
            adapter = CrossBluetoothLE.Current.Adapter;
            deviceList = new ObservableCollection<IDevice>();
            lv.ItemsSource = deviceList;
        }

I am new to Xamarin form so maby i missed something. My solution is available here.
https://github.com/Sisypos/BluetoothTUT

Any help is appreciated.

Developer technologies | .NET | Xamarin
0 comments No comments

1 answer

Sort by: Most helpful
  1. JarvanZhang 23,971 Reputation points
    2021-07-30T06:30:34.61+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    I download your sample and sign in as an apk. Then install the apk on a physical device, the application works as expected. It seems there is nothing wrong with the code. The problem should be caused by the way you archive the project. We need to sign the apk after archiving, please make sure the steps are all correct. You could check the following doc:
    https://learn.microsoft.com/en-us/xamarin/android/deploy-test/signing/?tabs=windows

    And how do you set the configs about the release mode? I package your sample without modifying any settings. If it still doesn't work after signing the apk, try to uninstall the application from the test device and clear the application data, then reinstall the apk. Or try to install the apk on another physical device for test.

    Best Regards,

    Jarvan Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.