Reputation: 976
I am developing a both(IOS and Android)
application using Xamarin Forms
.
I am trying to run my application Android
version but unfortunately app is crashing after splash screen.
I have tried with Emulator
as well as physical device(Moto G3)
.
I have updated the Xamarin studio
with latest stable
release. I have tried with changing the working solution directory
but same issue persist.
I have kept the breakpoint in SplashActivity OnCreate()
but debugger didn't come to this line.
IDE - Xamarin Studio 6.1.1(build 17)
OS - Mac OS 10.11.5
Xamarin.Android -7.0.1.3
SplashActivity.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Util;
using Android.Views;
using Android.Widget;
namespace SampleApp.Droid
{
[Activity(Label = "SampleApp",Theme = "@style/MyTheme.Splash", MainLauncher = true)]
public class signup : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Create your application here
}
protected override void OnResume()
{
base.OnResume();
Task startupWork = new Task(() =>
{
//Log.Debug(TAG, "Performing some startup work that takes a bit of time.");
Task.Delay(5000); // Simulate a bit of startup work.
//Log.Debug(TAG, "Working in the background - important stuff.");
});
startupWork.ContinueWith(t =>
{
//Log.Debug(TAG, "Work is finished - start Activity1.");
StartActivity(new Intent(Application.Context, typeof(MainActivity)));
}, TaskScheduler.FromCurrentSynchronizationContext());
startupWork.Start();
}
}
}
MainActivity.cs
using System;
using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Acr.UserDialogs;
using Xamarin.Forms;
using Plugin.Toasts;
using XLabs.Platform.Services;
using XLabs.Platform.Device;
using XLabs.Platform.Services.Media;
using XLabs.Ioc;
namespace SampleApp.Droid
{
[Activity(Label = "SampleApp.Droid", Icon = "@drawable/icon", Theme = "@style/MyTheme", MainLauncher = false, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
UserDialogs.Init(this);
SetXLabsInitialization();
LoadApplication(new App());
}
private void SetXLabsInitialization()
{
var container = new SimpleContainer();
container.Register<IDevice>(t => AndroidDevice.CurrentDevice)
.Register<IPhoneService>(t => t.Resolve<IDevice>().PhoneService)
.Register<IAudioStream>(t => t.Resolve<IDevice>().Microphone)
.Register<INetwork>(t => t.Resolve<IDevice>().Network)
.Register<IDependencyContainer>(container);
Resolver.SetResolver(container.GetResolver());
}
}
}
Application Output
Forwarding debugger port 8883
Detecting existing process
> am start -n "com.excelblaze.SampleApp/md51642ab35ccd81a05989cf18bf9b46112.signup"
> Starting: Intent { cmp=com.excelblaze.SampleApp/md51642ab35ccd81a05989cf18bf9b46112.signup }
Loaded assembly: SampleApp.Droid.dll
Loaded assembly: Mono.Android.Export.dll [External]
Loaded assembly: Xamarin.Android.Support.v4.dll [External]
Loaded assembly: Xamarin.Android.Support.Vector.Drawable.dll [External]
Loaded assembly: Xamarin.Android.Support.Animated.Vector.Drawable.dll [External]
Loaded assembly: Xamarin.Android.Support.v7.AppCompat.dll [External]
Loaded assembly: Xamarin.Android.Support.v7.RecyclerView.dll [External]
Loaded assembly: Xamarin.Android.Support.Design.dll [External]
Loaded assembly: Xamarin.Android.Support.v7.CardView.dll [External]
Loaded assembly: Xamarin.Android.Support.v7.MediaRouter.dll [External]
Loaded assembly: Xamarin.Forms.Platform.Android.dll [External]
Loaded assembly: FormsViewGroup.dll [External]
Loaded assembly: Xamarin.Forms.Core.dll [External]
Loaded assembly: Xamarin.Forms.Xaml.dll [External]
Loaded assembly: Xamarin.Forms.Platform.dll [External]
Loaded assembly: AndHUD.dll [External]
Loaded assembly: Splat.dll [External]
Loaded assembly: Acr.Support.Android.dll [External]
Loaded assembly: Acr.UserDialogs.dll [External]
Loaded assembly: Acr.UserDialogs.Interface.dll [External]
Loaded assembly: Newtonsoft.Json.dll [External]
Loaded assembly: Rg.Plugins.Popup.dll [External]
Loaded assembly: Rg.Plugins.Popup.Droid.dll [External]
Loaded assembly: Xamarin.GooglePlayServices.Basement.dll [External]
Loaded assembly: Xamarin.GooglePlayServices.Base.dll [External]
Loaded assembly: Xamarin.GooglePlayServices.Maps.dll [External]
Loaded assembly: Xamarin.Forms.Maps.Android.dll [External]
Loaded assembly: Xamarin.Forms.Maps.dll [External]
Loaded assembly: Toasts.Forms.Plugin.Abstractions.dll [External]
Loaded assembly: Toasts.Forms.Plugin.Droid.dll [External]
Loaded assembly: ExifLib.dll [External]
Loaded assembly: XLabs.Core.dll [External]
Loaded assembly: XLabs.Platform.dll [External]
Loaded assembly: XLabs.Platform.Droid.dll [External]
Loaded assembly: XLabs.Ioc.dll [External]
Loaded assembly: SampleApp.dll
Loaded assembly: XamForms.Controls.Calendar.dll [External]
Loaded assembly: Plugin.Geolocator.Abstractions.dll [External]
Loaded assembly: Plugin.Geolocator.dll [External]
Loaded assembly: Mono.Android.dll [External]
Loaded assembly: Java.Interop.dll [External]
Loaded assembly: System.dll [External]
Loaded assembly: System.Core.dll [External]
Error/Warning - build output
Build started 10/31/2016 7:20:04 PM.
__________________________________________________
Project "/Users/umar_shazuli/Documents/Umar/SA/WorkingCode/SA_31_10_2016/Mobile/UITests/SampleApp.UITests.csproj" (Build target(s)):
Target PrepareForBuild:
Configuration: Debug Platform: AnyCPU
Target ResolveProjectReferences:
Project "/Users/umar_shazuli/Documents/Umar/SA/WorkingCode/SA_31_10_2016/Mobile/iOS/SampleApp.iOS.csproj" (GetTargetPath target(s)):
/Users/umar_shazuli/Documents/Umar/SA/WorkingCode/SA_31_10_2016/Mobile/iOS/SampleApp.iOS.csproj: warning : Target '_CopyOutOfDateSourceItemsToOutputDirectory', not found in the project
/Users/umar_shazuli/Documents/Umar/SA/WorkingCode/SA_31_10_2016/Mobile/iOS/SampleApp.iOS.csproj: warning : Target 'XapPackager', not found in the project
Target BclBuildValidateNugetPackageReferences:
: warning : All projects referencing SampleApp.iOS.csproj must install nuget package MSArosoft.Bcl.Build. For more information, see http://go.mSArosoft.com/fwlink/?LinkID=317569.
Done building project "/Users/umar_shazuli/Documents/Umar/SA/WorkingCode/SA_31_10_2016/Mobile/iOS/SampleApp.iOS.csproj".
Project "/Users/umar_shazuli/Documents/Umar/SA/WorkingCode/SA_31_10_2016/Mobile/Droid/SampleApp.Droid.csproj" (GetTargetPath target(s)):
Target BclBuildValidateNugetPackageReferences:
: warning : All projects referencing SampleApp.Droid.csproj must install nuget package MSArosoft.Bcl.Build. For more information, see http://go.mSArosoft.com/fwlink/?LinkID=317569.
Done building project "/Users/umar_shazuli/Documents/Umar/SA/WorkingCode/SA_31_10_2016/Mobile/Droid/SampleApp.Droid.csproj".
Target GenerateSatelliteAssemblies:
No input files were specified for target GenerateSatelliteAssemblies, skipping.
Target _GenerateTargetFrameworkMonikerAttribute:
Skipping target "_GenerateTargetFrameworkMonikerAttribute" because its outputs are up-to-date.
Target CoreCompile:
Skipping target "CoreCompile" because its outputs are up-to-date.
Done building project "/Users/umar_shazuli/Documents/Umar/SA/WorkingCode/SA_31_10_2016/Mobile/UITests/SampleApp.UITests.csproj".
Build succeeded.
Warnings:
/Users/umar_shazuli/Documents/Umar/SA/WorkingCode/SA_31_10_2016/Mobile/UITests/SampleApp.UITests.csproj (Build) ->
/Library/Frameworks/Mono.framework/Versions/4.6.1/lib/mono/xbuild/14.0/bin/MSArosoft.Common.targets (ResolveProjectReferences target) ->
/Users/umar_shazuli/Documents/Umar/SA/WorkingCode/SA_31_10_2016/Mobile/iOS/SampleApp.iOS.csproj (GetTargetPath) ->
/Users/umar_shazuli/Documents/Umar/SA/WorkingCode/SA_31_10_2016/Mobile/iOS/SampleApp.iOS.csproj: warning : Target '_CopyOutOfDateSourceItemsToOutputDirectory', not found in the project
/Users/umar_shazuli/Documents/Umar/SA/WorkingCode/SA_31_10_2016/Mobile/iOS/SampleApp.iOS.csproj: warning : Target 'XapPackager', not found in the project
/Users/umar_shazuli/Documents/Umar/SA/WorkingCode/SA_31_10_2016/Mobile/UITests/SampleApp.UITests.csproj (Build) ->
/Library/Frameworks/Mono.framework/Versions/4.6.1/lib/mono/xbuild/14.0/bin/MSArosoft.Common.targets (ResolveProjectReferences target) ->
/Users/umar_shazuli/Documents/Umar/SA/WorkingCode/SA_31_10_2016/Mobile/iOS/SampleApp.iOS.csproj (GetTargetPath) ->
/Users/umar_shazuli/Documents/Umar/SA/WorkingCode/SA_31_10_2016/Mobile/packages/MSArosoft.Bcl.Build.1.0.21/build/MSArosoft.Bcl.Build.targets (BclBuildValidateNugetPackageReferences target) ->
: warning : All projects referencing SampleApp.iOS.csproj must install nuget package MSArosoft.Bcl.Build. For more information, see http://go.mSArosoft.com/fwlink/?LinkID=317569.
/Users/umar_shazuli/Documents/Umar/SA/WorkingCode/SA_31_10_2016/Mobile/UITests/SampleApp.UITests.csproj (Build) ->
/Library/Frameworks/Mono.framework/Versions/4.6.1/lib/mono/xbuild/14.0/bin/MSArosoft.Common.targets (ResolveProjectReferences target) ->
/Users/umar_shazuli/Documents/Umar/SA/WorkingCode/SA_31_10_2016/Mobile/Droid/SampleApp.Droid.csproj (GetTargetPath) ->
/Users/umar_shazuli/Documents/Umar/SA/WorkingCode/SA_31_10_2016/Mobile/packages/MSArosoft.Bcl.Build.1.0.21/build/MSArosoft.Bcl.Build.targets (BclBuildValidateNugetPackageReferences target) ->
: warning : All projects referencing SampleApp.Droid.csproj must install nuget package MSArosoft.Bcl.Build. For more information, see http://go.mSArosoft.com/fwlink/?LinkID=317569.
4 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.5679990
---------------------- Done ----------------------
Build: 0 errors, 12 warnings
Upvotes: 0
Views: 2148
Reputation: 64
If the SplashActivity launches but crashes afterwards i would suggest that you comment out the following.
On MainActivity in OnCreate to narrow down the problem:
It could be that one of these requires assemblies that is not present.
If those initializations are not breaking it then look for Xaml errors in the Xamarin Diagnostics Output log.
Upvotes: 1