• Latest
Integrating AppGallery Connect Crash in a Xamarin App for Android

Integrating AppGallery Connect Crash in a Xamarin App for Android

December 16, 2021
Fireworks photos made easy: Getting the most bang out of your images

Fireworks photos made easy: Getting the most bang out of your images

July 1, 2022
Nintendo Launches Subscription Service For Switch Repairs In Japan

Nintendo Launches Subscription Service For Switch Repairs In Japan

July 1, 2022
Kao the Kangaroo roadmap promises achievement fixes

Kao the Kangaroo roadmap promises achievement fixes

July 1, 2022
OnePlus 7 and 7T are finally getting Android 12

OnePlus 7 and 7T are finally getting Android 12

July 1, 2022
Xbox Cloud Gaming launches on Samsung smart TVs

Xbox Cloud Gaming launches on Samsung smart TVs

July 1, 2022
FIST: Forged In Shadow Torch Gets Physical Edition In September

FIST: Forged In Shadow Torch Gets Physical Edition In September

July 1, 2022
Google settles lawsuit with US app developers for $90 million

Google settles lawsuit with US app developers for $90 million

July 1, 2022
OnePlus Nord 2T debuts in India, sales begin July 5

OnePlus Nord 2T debuts in India, sales begin July 5

July 1, 2022
Fire Emblem Warriors: Three Hopes Was Originally Fire Emblem Warriors 2

Fire Emblem Warriors: Three Hopes Was Originally Fire Emblem Warriors 2

July 1, 2022
OnePlus Nord 2T 5G hands-on review

OnePlus Nord 2T 5G hands-on review

July 1, 2022
Apple now selling refurbished Mac Studio models, priced at a 10% discount compared to buying new

Apple now selling refurbished Mac Studio models, priced at a 10% discount compared to buying new

July 1, 2022
Apple launches Apple TV promotion: get a $50 gift card with Apple TV 4K or Apple TV HD purchase

Apple launches Apple TV promotion: get a $50 gift card with Apple TV 4K or Apple TV HD purchase

July 1, 2022
Advertise with us
Friday, July 1, 2022
Bookmarks
  • Login
  • Register
GetUpdated
  • Home
  • Game Updates
    • Mobile Gaming
    • Playstation News
    • Xbox News
    • Switch News
    • MMORPG
    • Game News
    • IGN
    • Retro Gaming
  • Tech News
    • Apple Updates
    • Jailbreak News
    • Mobile News
  • Software Development
  • Photography
  • Contact
    • Advertise With Us
    • About
No Result
View All Result
GetUpdated
No Result
View All Result
GetUpdated
No Result
View All Result
ADVERTISEMENT

Integrating AppGallery Connect Crash in a Xamarin App for Android

December 16, 2021
in Software Development
Reading Time:6 mins read
0 0
0
Share on FacebookShare on WhatsAppShare on Twitter


Today, we are going to take a look at how we can integrate the AppGallery Connect crash service into your Xamarin app.

But why might you want to do this? The AppGallery Connect Crash service provides a powerful yet lightweight solution to app crash problems. With the service, you can quickly detect, locate, and resolve app crashes (unexpected exits of apps), and have access to highly readable crash reports in real-time, without the need to write any code.

The service is completely free to use and can be a great addition to your project!

Below is a simple app example you can follow along with to get a good idea of how you might use this service in your own app!

Preparing the Xamarin Environment and Configuring Your Project

Install the Xamarin environment.

You’ll need to install Visual Studio first, and then select Mobile development with .NET in Visual Studio to install the Xamarin environment. 

Installing Visual Studio.

Create a project in AppGallery Connect and enable HUAWEI Analytics for your project.

Install the service SDK. Right-click your project and choose Manage NuGet Packages

Installing the services.

Search for crash on the Browse tab. Click Xamarin.Android bindings for HMS Core — AgconnectCrash in the search results, and install it. 

Search for Crash.

Add the JSON file to the Assets directory.

Add the JSON file.

Next, implement LazyInputStream to read the agconnect-services.json file. For details, please refer to Getting Started with Xamarin. Finally, set a package name in Android Manifest.

Set a package name.

Example Application

Let’s start by creating a simple layout that has three buttons. 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:orientation="vertical">

        <Button
            android:id="@+id/btn_crash"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textAllCaps="false"
            android:text="MakeCrash" />

        <Button
            android:id="@+id/btnRecordException"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textAllCaps="false"
            android:text="CatchException" />

        <Button
            android:id="@+id/btnCustomReport"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textAllCaps="false"
            android:text="CustomReport" />

    </LinearLayout>
</LinearLayout>

String app name.

In the MainActivity.cs file, call * AGConnectCrash.Instance.TestIt* to trigger a crash.

  • Call AGConnectCrash.Instance.SetUserId to set a custom user ID.
  • Call AGConnectCrash.Instance.SetCustomKey to set the key and value for a custom key-value pair. 
  • Call AGConnectCrash.Instance.Log to set the log level.
  • Call AGConnectCrash.Instance.RecordException to record a non-fatal exception.
private void BtnCreateCrash_Click(object sender, EventArgs e) {
  AGConnectCrash.Instance.TestIt(this);
}

private void BtnCustomReport_Click(object sender, EventArgs e) {
  AGConnectCrash.Instance.SetUserId("testuser");
  AGConnectCrash.Instance.SetCustomKey("doublekey", "1.1");
  AGConnectCrash.Instance.SetCustomKey("floatkey", "1.12f");
  AGConnectCrash.Instance.SetCustomKey("intkey", "123");
  AGConnectCrash.Instance.SetCustomKey("stringkey", "hello world");
  AGConnectCrash.Instance.Log("default log level");
  AGConnectCrash.Instance.Log(3, "3 is debug log level");

}

private void BtnRecordException_Click(object sender, EventArgs e) {
  try {
    ArrayIndexOutOfBoundsException arrayIndexOutOfBoundsException = new ArrayIndexOutOfBoundsException();
    throw arrayIndexOutOfBoundsException;
  } catch (Java.Lang.Exception ex) {
    AGConnectCrash.Instance.RecordException(ex);
  }
}

View the Crash Report

Tap MakeCrash, CatchException, and CustomReport in sequence, and check the report in AppGallery Connect.

Crash statistics: 

Crash statistics screenshot.

Exceptions:
Exceptions screenshot.

Debugging:
Debugging screenshot.

View custom key-value pairs:
Custom key-value pairs.

View custom log level:
Custom log-level view.

View custom user IDs:
Custom user IDs.

For more information, please refer to the following:



Source link

ShareSendTweet
Previous Post

GTO SNOW

Next Post

Latest Disney+ update enables Apple SharePlay support

Related Posts

MongoDB vs DynamoDB Head-to-Head – DZone Database

July 1, 2022
0
0
MongoDB vs DynamoDB Head-to-Head – DZone Database
Software Development

Databases are a key architectural component of many applications and services. Traditionally, organizations have chosen relational databases like SQL Server,...

Read more

Understanding Kubernetes Resource Types – DZone Cloud

July 1, 2022
0
0
Understanding Kubernetes Resource Types – DZone Cloud
Software Development

Note: This is the first of a five-part series covering Kubernetes resource management and optimization. We start by describing Kubernetes...

Read more
Next Post
Latest Disney+ update enables Apple SharePlay support

Latest Disney+ update enables Apple SharePlay support

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

© 2021 GetUpdated – MW.

  • About
  • Advertise
  • Privacy & Policy
  • Terms & Conditions
  • Contact

No Result
View All Result
  • Home
  • Game Updates
    • Mobile Gaming
    • Playstation News
    • Xbox News
    • Switch News
    • MMORPG
    • Game News
    • IGN
    • Retro Gaming
  • Tech News
    • Apple Updates
    • Jailbreak News
    • Mobile News
  • Software Development
  • Photography
  • Contact
    • Advertise With Us
    • About

Welcome Back!

Login to your account below

Forgotten Password? Sign Up

Create New Account!

Fill the forms bellow to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?