I am working on UWP application, using Prism 6.0
My application is working totally fine in both Debug and Release modes but when i am running Windows App Certification Kit on the app packages, I keep getting this Application error - "Session state service failed". I have never seen this exception when I am installing the app packages and running the app. But I get this exception every time when WACK is running the packages.
Because of this,
I am getting error in Windows App Certification Kit - Test Results.
The error are:
FAILED
Crashes and hangs
•Error Found: The crashes and hangs test detected the following errors:◦Executable C:\Program Files\WindowsApps\10486username.SongApp_1.1.0.0_x86__5q2wmk4fv784y\SongApp.exe was detected by Windows Error Reporting and experienced a crash or hang.
◦Application 10486username.SongApp_1.1.0.0_x86__5q2wmk4fv784y was detected by Windows Error Reporting and experienced a crash or hang.
•Impact if not fixed: An app that stops responding or crashes can cause data loss and is a poor user experience.
•How to fix: Investigate and debug the app to identify and fix the problem.
FAILED
Direct3D trim after suspend
•Error Found: The Direct3D Trim after Suspend test detected the following errors:◦Application App was not running at the end of the test. It likely crashed or was terminated for having become unresponsive.
•Impact if not fixed: If the app does not call Trim on its Direct3D device, the app will not release memory allocated for its earlier 3D work. This increases the risk of apps being terminated due to system memory pressure.
•How to fix: The app should call the Trim API on its IDXGIDevice3 interface anytime it is about to be suspended.
I've built a repro with the Prism sandbox app creating a new type as model, have it serialized on suspension and watch it crash through hitting Suspend and shutdown as application lifecycle event in the Debug location toolbar.
namespace HelloWorld.Models
{
public class MyModel
{
public MyModel() {}
public MyModel(string someText)
{
SomeText = someText;
}
public string SomeText { get; set; }
}
}
In the viewmodel:
[RestorableState]
public MyModel MyModel
{
get { return _myModel; }
set { SetProperty(ref _myModel, value); }
}
After some research, I managed to solve the crash by adding following lines in the runtime directives (Default.rd.xml) file:
<!-- Add your application specific runtime directives here. -->
<Namespace Name="HelloWorld.Models" Serialize="Required PublicAndInternal">
<Type Name="MyModel" Browse="Required Public" DataContractSerializer="Required Public"/>
</Namespace>
DataContractSerializer
Optional attribute. Controls policy for serialization that uses the System.Runtime.Serialization.DataContractSerializer class.
Source: MSDN
Related
I'm new to XamarinUITest and I am having trouble running it on real devices locally (in preparation for AppCenter Test).
When I run it using an Android emulator, the test runs smoothly, passes and completes.
When I run it on a real device connected to my machine (OnePlus 5T) I get the following issues:
Message:
System.Exception : Post to endpoint '/ping' failed after 100 retries. No http result received
Stack Trace:
AppInitializer.StartApp(Platform platform) line 24
Login.BeforeEachTest() line 25
Standard Output:
Full log file: C:\Users\Steve\AppData\Local\Temp\uitest\log-2021-11-25_13-54-49-953.txt
Skipping IDE integration as important properties are configured. To force IDE integration, add .PreferIdeSettings() to ConfigureApp.
Android test running Xamarin.UITest version: 3.2.3
Initializing Android app on device 3acaec7 with apk: C:\Users\Steve\source\repos\MyTestApp\MyTestApp.Android\bin\Dev\com.mytestapp.dev-Signed.apk
Skipping local screenshots. Can be enabled with EnableScreenshots() when configuring app.
Signing apk with Xamarin keystore.
I have internet permissions on in my AndroidManifest.xml file.
AppInitializer
public static IApp StartApp(Platform platform)
{
try
{
if (platform == Platform.Android)
return ConfigureApp.Android.ApkFile(#"C:\Users\Steve\source\repos\MyTestApp\MyTestApp.Android\bin\Dev\com.mytestapp.dev-Signed.apk").StartApp();
else
return ConfigureApp.iOS.StartApp();
}
catch(Exception ex)
{
throw(ex);
}
}
I get this same issue if I try upload it to AppCenter. If I run the app when the APK file is already on the device then the test loading indicator keeps spinning forever.
I have tried .InstalledApp() instead and also had no luck on real devices. This is v important so I really appreciate everyone chimming in. Thanks.
I have a finished application which I would like to make available to run on the iOS and Android platforms. I have tested the application as much as possible and it works without problem. But I know there is always the chance that something might go wrong and I could get an exception.
My question is how can I deal with this or what should I do. What happens on the phone, if a Forms application is deployed and there is an exception.
Would appreciate any advice or even links as to how this is handled.
If an exception is thrown and not handled by your code, the app will stop working (i.e. crash).
In order to handle these crashes we are using MS AppCenter (the successor to HockeyApp/Xamarin AppInsights).
You'll have to create a project there (one for each platform), and add the NuGet package to your projects. Afterwards you can initialize it with
AppCenter.Start("ios={Your App Secret};android={Your App Secret}",
typeof(Crashes)); // you'll get the app secrets from appcenter.ms
Crashes will be logged to AppCenter now and you'll be informed whenever there is a new crash.
Please note that it's best practice (if not required by law), that you ask the user for consent before sending the crash report (see here). You are using the delegate Crashes.ShouldAwaitUserConfirmation for that matter. You could for example show an action sheet with Acr.UserDialogs
private bool AwaitUserConfirmation()
{
// you should of course use your own strings
UserDialogs.Instance.ActionSheet(
new ActionSheetConfig
{
Title = "Oopsie",
Message = "The app crashed. Send crash to developers.",
Options = new List<ActionSheetOption>
{
new ActionSheetOption("Sure", () => Crashes.NotifyUserConfirmation(UserConfirmation.Send)),
new ActionSheetOption("Yepp, and don't bug be again.", () => Crashes.NotifyUserConfirmation(UserConfirmation.AlwaysSend)),
new ActionSheetOption("Nope", () => Crashes.NotifyUserConfirmation(UserConfirmation.DontSend))
}
});
return true;
}
I am using Visual Studio App Center for my Xamarin Forms Android Application for capturing the Analytics(Events and Crashes)
I am configuring crashes and analytics in OnStart of my App.Xaml.cs
AppCenter.Start($"android={Settings.Current.AppCenterAnalyticsAndroid};" +
typeof(Analytics), typeof(Crashes));
And for invoking the Events I am calling the below Method.
public void TrackEvent(string name, Dictionary<string, string> properties = null)
{
Analytics.SetEnabledAsync(true).ConfigureAwait(false);
Analytics.TrackEvent(name, properties);
}
Crashes are logging correctly in App Center But the events are not.
Also I can see the corresponding entries in Log Flow
Your app secret string is invalid because it contains + typeof(Analytics), it should be , typeof(Analytics).
Since you used the android key/value delimiter we could extract the appSecret and make it work with Crashes, but typeof(Analytics) ended up in the wrong appSecret parameter string.
You shouldn't need to add Analytics.SetEnabledAsync(true).ConfigureAwait(false);
Simply Call Analytics.TrackEvent(name, properties); (it doesn't need to be in a task anyways. I track my events in the Construtor of pages, for example.
Also, when you run the application, you get a debug Message confirming that AppCenter has been configured correctly, check if that is the case.
And, it may take a while, for them to appear in the Events.
I have an Android Application that works with locals instalations and I want use it with diferents Parse applications. Each instalation administrator will contract with Parse directly. When app start it will look for the keys for parse.
I wonder how to change the Parse App linkeded in the Android App once this is running
I have tried to call Parse.initialize (context, apllicationId, clientKey) twice but it doesn't work. I have tried the app register in diferent Parse App every time you start the App link with a different Parse App
It´s always linked only with the first application
public void onCreate(final Bundle icicle){
super.onCreate(icicle);
final Context context = this;
setContentView(R.layout.ssa);
getActionBar().hide();
// Getting the global variables
fmGlobalsBean = Utilities.getGlobals(this);
if(!"".equals(fmGlobalsBean.getUrl_server())){
Parse.initialize(contexto, "p4IWkTRc0WTdKkMH6r60hjYzwX1TIXChy8VcDvPb", "KhkcX4G3dqVpRawHyIYfnHAWqj1H2vyhwD3wINlQ");
ParseInstallation.getCurrentInstallation().saveInBackground();
ParsePush.subscribeInBackground(fmGlobalsBean.getUrl_server());
}
else
{
Parse.initialize(this, "Y3xgZ58u4Qcn9TrovFqCOe4PBzhURjXooZ3vDKgB", "ealo3nm4wa4lbJ7KrSR2OSf60DZiUjEUjdUJTQzs");
ParseInstallation.getCurrentInstallation().saveInBackground();
ParsePush.subscribeInBackground("INITIAL");
}
}
Exceptions:
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.IO.IsolatedStorage.IsolatedStorageException' occurred in mscorlib.dll
public static IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
private void GetScoreData()
{
if (settings.Contains(dataItem2.Name))
{
this.textBlock2.Text = settings[dataItem2.Name].ToString();
}
else
{
settings.Add(dataItem2.Name, "N/A");
this.textBlock2.Text = "N/A";
}
settings.Save();
}
now in the other page
i am updating its value by doing this
ScorePage.settings["MyKey"] = moves.ToString();
so everytime i restart my emulator and run my project this exception comes.
any reason why?
The isolated storage in the emulator is not persisted after you close it.
Reference: Windows Phone Emulator: (see features)
Isolated storage is available while the emulator is running. Data in isolated storage does not persist after the emulator closes. This includes files stored in a local database, as these files reside in isolated storage.
I suggest you to use site settings over application settings.
One more thing, dont worry the windows phone is persistent.(only the emulator is not!)
After restarting the emulator (or reinstallign the app), the contents on IsolatedStorage will be deleted. If you're trying to update a setting, first check that the key exists.
Showing the line where the exception occurs and the exact text of the exception will also help with identifying the issue.