vendredi 30 août 2019

How to add AppCenter support to your Android Kotlin Project.

In order to be able to receive information about your Kotlin project in the AppCenter.ms consoles, in your Android project, in the MainActivity activity :

1- Import the following libraries :

import com.microsoft.appcenter.AppCenter
import com.microsoft.appcenter.analytics.Analytics
import com.microsoft.appcenter.crashes.Crashes

2- Enable Appcenter with the following line of code in the onCreate overrided method :

AppCenter.start(getApplication(), "eeeeeeee-xxxx-yyyy-zzzz-aaaaaaaaaaaa",Analytics::class.java, Crashes::class.java)

3- Don't forget to replace the key by the one generated for your account in AppCenter ("eeeeeeee..." by the new one)

4- In App/build.gradle file, add :

dependencies {
    def appCenterSdkVersion = '2.3.0'
    implementation "com.microsoft.appcenter:appcenter-analytics:${appCenterSdkVersion}"
    implementation "com.microsoft.appcenter:appcenter-crashes:${appCenterSdkVersion}"
}

That's it !