Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Xamarin Android build is getting fail with ".xaml : error : Object reference not set to an instance"

I am building xamarin apk package from vsts getting fail with below error,

Views\ListPage.xaml : error : Object reference not set to an instance of an object. [D:\a\5\s\DevOps\DevApp\DevApp.csproj]

Please help to resolve the same.

Answers

  • jezhjezh Member, Xamarin Team Xamurai
    edited December 2018

    It would be great if you could provide a small sample that reproduces the crash.

  • vikram_kvikram_k Member ✭✭

    Hi Jezh, thanks for reply,

    Please find below the error log,

    Using shared compilation with compiler from directory: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Roslyn
    XamlC:
    Compiling Xaml, assembly: obj\Release\Ecolab.EnvisionApps.ControllerApp.dll
    01.7957106Z ##[error]Views\AlarmsCustomersListPage.xaml(0,0): Error : Object reference not set to an instance of an object.
    01.7958356Z Views\AlarmsCustomersListPage.xaml : error : Object reference not set to an instance of an object. [D:\a\5\s\DevOps\DevApp\DevApp.csproj]
    01.9754972Z ##[error]Views\AlarmDetailsPage.xaml(0,0): Error : Object reference not set to an instance of an object.
    02.0482247Z Views\AlarmDetailsPage.xaml : error : Object reference not set to an instance of an object. [D:\a\5\s\DevOps\DevApp\DevApp.csproj]
    02.0485549Z ##[error]Views\ControllersListPage.xaml(0,0): Error : Object reference not set to an instance of an object.
    02.0486634Z Views\ControllersListPage.xaml : error : Object reference not set to an instance of an object. [D:\a\5\s\DevOps\DevApp\DevApp.csproj]
    02.2409026Z ##[error]Views\UserProfilePage.xaml(0,0): Error : Object reference not set to an instance of an object.
    02.2409666Z Views\UserProfilePage.xaml : error : Object reference not set to an instance of an object. [D:\a\5\s\DevOps\DevApp\DevApp.csproj]
    02.2874613Z ##[error]Templates\AlarmsListTemplate.xaml(0,0): Error : Object reference not set to an instance of an object.
    02.2875232Z Templates\AlarmsListTemplate.xaml : error : Object reference not set to an instance of an object. [D:\a\5\s\DevOps\DevApp\DevApp.csproj]
    02.3027772Z ##[error]Templates\CustomersListTemplate.xaml(0,0): Error : Object reference not set to an instance of an object.
    02.3028290Z Templates\CustomersListTemplate.xaml : error : Object reference not set to an instance of an object. [D:\a\5\s\DevOps\DevApp\DevApp.csproj]
    02.3985714Z ##[error]Templates\NavigationBarView.xaml(0,0): Error : Object reference not set to an instance of an object.
    02.3986700Z Templates\NavigationBarView.xaml : error : Object reference not set to an instance of an object. [D:\a\5\s\DevOps\DevApp\DevApp.csproj]
    02.5348902Z ##[error]Views\AlarmsChatPage.xaml(0,0): Error : Object reference not set to an instance of an object.
    02.5350246Z Views\AlarmsChatPage.xaml : error : Object reference not set to an instance of an object. [D:\a\5\s\DevOps\DevApp\DevApp.csproj]
    02.6517908Z ##[error]Templates\AlarmsByControllerListItemTemplate.xaml(0,0): Error : Object reference not set to an instance of an object.
    02.6518568Z Templates\AlarmsByControllerListItemTemplate.xaml : error : Object reference not set to an instance of an object. [D:\a\5\s\DevOps\DevApp\DevApp.csproj]
    02.7495106Z ##[error]Templates\AlarmsHistoryListItemTemplate.xaml(0,0): Error : Object reference not set to an instance of an object.
    02.7496010Z Templates\AlarmsHistoryListItemTemplate.xaml : error : Object reference not set to an instance of an object. [D:\a\5\s\DevOps\DevApp\DevApp.csproj]
    02.7773587Z ##[error]Views\AlarmLimitSetPointChangePage.xaml(0,0): Error : Object reference not set to an instance of an object.
    02.7774538Z Views\AlarmLimitSetPointChangePage.xaml : error : Object reference not set to an instance of an object. [D:\a\5\s\DevOps\DevApp\DevApp.csproj]
    02.7934797Z ##[error]Views\AlarmDetailsGraphPage.xaml(0,0): Error : Object reference not set to an instance of an object.
    02.7935547Z Views\AlarmDetailsGraphPage.xaml : error : Object reference not set to an instance of an object. [D:\a\5\s\DevOps\DevApp\DevApp.csproj]
    02.8096846Z ##[error]Views\AlarmManualRelayControlPage.xaml(0,0): Error : Object reference not set to an instance of an object.
    02.8097574Z Views\AlarmManualRelayControlPage.xaml : error : Object reference not set to an instance of an object. [D:\a\5\s\DevOps\DevApp\DevApp.csproj]
    02.8248029Z ##[error]Templates\AlarmManualRelayControlTemplate.xaml(0,0): Error : Object reference not set to an instance of an object.
    02.8248766Z Templates\AlarmManualRelayControlTemplate.xaml : error : Object reference not set to an instance of an object. [D:\a\5\s\DevOps\DevApp\DevApp.csproj]
    03.2672635Z Done Building Project "D:\a\5\s\DevOps\DevApp\DevApp.csproj" (default targets) -- FAILED.
    03.2691985Z Done Building Project "D:\a\5\s\DevOps\DevApp.Droid\DevApp.Droid.csproj" (Clean;clean;PackageForAndroid target(s)) -- FAILED.
    03.2715194Z
    03.2716915Z Build FAILED.
    03.2764828Z

  • jezhjezh Member, Xamarin Team Xamurai

    From the error log, we can see that you are trying to access an object without instantiating it.
    So you might need to use the new keyword to instantiate it first . i.e: create an instance of it.

    For example:

     public class  MyClass
     {
          public int Id {get; set;}
      }
    
       MyClass myClass;
       myClass.Id = 0; <----------- An error will be thrown here.. because myClass is null here...
    

    You will have to use:

        myClass = new MyClass();
        myClass.Id = 0;
    
Sign In or Register to comment.