title | description | author | ms.author | ms.date | ms.topic | ms.assetid | ms.service | ms.tgt_pltfrm |
---|---|---|---|---|---|---|---|---|
HockeySDK for Android Migration |
Migrate from the HockeySDK to App Center Android SDK |
lucen-ms |
lucen |
12/11/2023 |
article |
bfce1840-20b2-4589-a726-d6aacd645d91 |
vs-appcenter |
android |
[!INCLUDE Retirement announcement for App Center]
[!INCLUDE sdk migration dropdown]
Open the project's app level build.gradle file (app/build.gradle
) and replace the following line in the dependencies { ... }
configuration.
Before:
implementation 'net.hockeyapp.android:HockeySDK:...'
After:
def appCenterSdkVersion = '5.0.4'
implementation "com.microsoft.appcenter:appcenter-analytics:${appCenterSdkVersion}"
implementation "com.microsoft.appcenter:appcenter-crashes:${appCenterSdkVersion}"
implementation "com.microsoft.appcenter:appcenter-distribute:${appCenterSdkVersion}"
The App Center SDK is designed with a modular approach – you can integrate only those services that you're interested in. Each SDK module needs to be added as a separate dependency in this section. See the equivalences in the next table:
HockeyApp class | App Center module |
---|---|
MetricsManager |
Analytics |
CrashManager |
Crashes |
UpdateManager |
Distribute |
The App Center SDK uses application identifiers in the globally unique identifier (GUID) format. Your HockeyApp App ID can be used by App Center but you need to convert it to a different format. To convert the identifier you must add four hyphens to get an 8-4-4-4-12 representation.
Before (HockeyApp):
00112233445566778899aabbccddeeff
After (App Center):
00112233-4455-6677-8899-aabbccddeeff
-
Replace the following imports in your activity class.
Before:
import net.hockeyapp.android.CrashManager; import net.hockeyapp.android.metrics.MetricsManager; import net.hockeyapp.android.UpdateManager;
After:
import com.microsoft.appcenter.AppCenter; import com.microsoft.appcenter.analytics.Analytics; import com.microsoft.appcenter.crashes.Crashes; import com.microsoft.appcenter.distribute.Distribute;
-
Replace registration code inside your app's main activity class'
onCreate
-callback.Before:
CrashManager.register(this); MetricsManager.register(getApplication()); UpdateManager.register(this);
After:
AppCenter.start(getApplication(), "{Your App Secret}", Analytics.class, Crashes.class, Distribute.class);
If you used metadata to provide the application identifier, you must copy it from there to the initialization code and remove
<meta-data android:name="net.hockeyapp.android.appIdentifier" android:value="..." />
from your AndroidManifest.xml file.
-
Replace HockeyApp API calls throughout the application. The detailed API mapping tables are given below.
Feature | HockeyApp | App Center |
---|---|---|
Adjust the log level | HockeyLog.setLogLevel |
AppCenter.setLogLevel |
Identify installations | Internal only | AppCenter.getInstallId |
Identify users | Crashes only | AppCenter.setUserId |
Feature | HockeyApp | App Center |
---|---|---|
Automatically track sessions | Yes, can be disabled by MetricsManager.setSessionTrackingDisabled |
Documentation (can't be disabled) |
Custom events with properties | MetricsManager.trackEvent |
Analytics.trackEvent |
Disable service at runtime | MetricsManager.disableUserMetrics and MetricsManager.enableUserMetrics |
Analytics.setEnabled |
Feature | HockeyApp | App Center |
---|---|---|
Automatically send crashes | Disabled by default | Documentation (enabled by default) |
Attach additional meta data | Yes | Documentation (can be attached from listener) |
Customize user dialog | Yes | Documentation (not provided by default) |
Get info about the sending status | Yes | Documentation |
Info about a previous crash | CrashManager.getLastCrashDetails |
Crashes.getLastSessionCrashReport |
Note
Unlike in HockeyApp, App Center in-app updates feature only works with RELEASE builds (by default) that are distributed using the App Center Distribute service. If the app is using a private distribution group, once the app is installed and opened for the first time after the App Center Distribute SDK has been added, a browser will open to authenticate the user and enable in-app updates. This browser will also open if you set the private in-app update track at runtime. This is a ONE-TIME step that won't occur for subsequent releases of your app. Refer to the App Center Distribute Documentation for more details.
Feature | HockeyApp | App Center |
---|---|---|
Restricted in-app updates | LoginManager.verifyLogin |
Distribute.setUpdateTrack |
Disable service at runtime | UpdateManager.unregister |
Distribute.setEnabled |
Customize the update dialog | Yes | Documentation |
The feedback service won't be supported in App Center. See HockeyApp feedback.