Skip to content

Commit f7d4e23

Browse files
authored
Merge pull request #245 from Microsoft/develop
0.3.1
2 parents 4510574 + d81f300 commit f7d4e23

File tree

32 files changed

+541
-280
lines changed

32 files changed

+541
-280
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ captures/
3535

3636
# Intellij
3737
*.iml
38-
.idea/workspace.xml
3938
.idea/
4039

4140
# Keystore files

LICENSE.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

README.md

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
[![Build Status](https://www.bitrise.io/app/78891228f9c6e6dc.svg?token=KQ6kVAci490XBjulCcQuGQ&branch=develop)](https://www.bitrise.io/app/78891228f9c6e6dc)
22
[![codecov](https://codecov.io/gh/Microsoft/MobileCenter-SDK-Android/branch/develop/graph/badge.svg?token=YwMZRPnYK3)](https://codecov.io/gh/Microsoft/MobileCenter-SDK-Android)
3+
[![GitHub Release](https://img.shields.io/github/release/Microsoft/MobileCenter-SDK-Android.svg)](https://github.com/Microsoft/MobileCenter-SDK-Android/releases/latest)
4+
[![Bintray](https://img.shields.io/bintray/v/mobilecenter/mobilecenter/mobile-center.svg)](https://bintray.com/mobilecenter/mobilecenter)
5+
[![license](https://img.shields.io/badge/license-MIT%20License-yellow.svg)](https://github.com/Microsoft/MobileCenter-SDK-Android/blob/develop/license.txt)
36

47
# Mobile Center SDK for Android
58

@@ -40,46 +43,32 @@ The Mobile Center SDK is designed with a modular approach – a developer only n
4043

4144
Below are the steps on how to integrate our compiled libraries in your application using Android Studio and Gradle.
4245

43-
1. Open your app level build.gradle file (app/build.gradle) and add the following lines after `apply plugin`. During the private beta, you need to include these credentials in order to get the libraries.
44-
45-
```groovy
46-
repositories {
47-
maven {
48-
url 'http://mobilecenter.bintray.com/mobilecenter'
49-
credentials {
50-
username 'mobile-center'
51-
password '9263658ba66b541c798b704723cc020cb40c6f78'
52-
}
53-
}
54-
}
55-
```
56-
57-
2. In the same file, include the dependencies that you want in your project. Each SDK module needs to be added as a separate dependency in this section. If you would want to use both Analytics and Crashes, add the following lines:
46+
1. Open your app level build.gradle file (app/build.gradle) and include the dependencies that you want in your project. Each SDK module needs to be added as a separate dependency in this section. If you would want to use both Analytics and Crashes, add the following lines:
5847

5948
```groovy
6049
dependencies {
61-
def mobileCenterSdkVersion = '0.3.0'
50+
def mobileCenterSdkVersion = '0.3.1'
6251
compile "com.microsoft.azure.mobile:mobile-center-analytics:${mobileCenterSdkVersion}"
6352
compile "com.microsoft.azure.mobile:mobile-center-crashes:${mobileCenterSdkVersion}"
6453
}
6554
```
6655
67-
3. Save your build.gradle file and make sure to trigger a Gradle sync in Android Studio.
56+
2. Save your build.gradle file and make sure to trigger a Gradle sync in Android Studio.
6857
6958
Now that you've integrated the SDK in your application, it's time to start the SDK and make use of Mobile Center services.
7059
7160
## 3. Start the SDK
7261
7362
To start the Mobile Center SDK in your app, follow these steps:
7463
75-
1. **Start the SDK:** Mobile Center provides developers with two modules to get started – Analytics and Crashes. In order to use these modules, you need to opt in for the module(s) that you'd like, meaning by default no modules are started and you will have to explicitly call each of them when starting the SDK. Insert the following line inside your app's main activity class' `onCreate` callback.
64+
1. **Start the SDK:** Mobile Center provides developers with two services to get started – Analytics and Crashes. In order to use these services, you need to opt in for the service(s) that you'd like, meaning by default no services are started and you will have to explicitly call each of them when starting the SDK. Insert the following line inside your app's main activity class' `onCreate` callback.
7665
7766
```Java
7867
MobileCenter.start(getApplication(), "{Your App Secret}", Analytics.class, Crashes.class);
7968
```
8069
You can also copy paste the `start` method call from the Overview page on Mobile Center portal once your app is selected. It already includes the App Secret so that all the data collected by the SDK corresponds to your application. Make sure to replace {Your App Secret} text with the actual value for your application.
8170
82-
The example above shows how to use the `start()` method and include both the Analytics and Crashes module. If you wish not to use Analytics, remove the parameter from the method call above. Note that, unless you explicitly specify each module as parameters in the start method, you can't use that Mobile Center service. Also, the `start()` API can be used only once in the lifecycle of your app – all other calls will log a warning to the console and only the modules included in the first call will be available.
71+
The example above shows how to use the `start()` method and include both the Analytics and Crashes services. If you wish not to use Analytics, remove the parameter from the method call above. Note that, unless you explicitly specify each service as parameters in the start method, you can't use that Mobile Center service. Also, the `start()` API can be used only once in the lifecycle of your app – all other calls will log a warning to the console and only the services included in the first call will be available.
8372
8473
Android Studio will automatically suggest the required import statements once you insert the `start()` method-call, but if you see an error that the class names are not recognized, add the following lines to the import statements in your activity class:
8574
@@ -91,7 +80,7 @@ To start the Mobile Center SDK in your app, follow these steps:
9180
9281
## 4. Analytics APIs
9382
94-
* **Track Session, Device Properties:** Once the Analytics module is included in your app and the SDK is started, it will automatically track sessions, device properties like OS Version, model, manufacturer etc. and you don’t need to add any additional code.
83+
* **Track Session, Device Properties:** Once the Analytics service is included in your app and the SDK is started, it will automatically track sessions, device properties like OS Version, model, manufacturer etc. and you don’t need to add any additional code.
9584
Look at the section above on how to [Start the SDK](#3-start-the-sdk) if you haven't started it yet.
9685
9786
* **Custom Events:** You can track your own custom events with specific properties to know what's happening in your app, understand user actions, and see the aggregates in the Mobile Center portal. Once you have started the SDK, use the `trackEvent()` method to track your events with properties.
@@ -110,21 +99,21 @@ To start the Mobile Center SDK in your app, follow these steps:
11099
Analytics.trackEvent("Video clicked");
111100
```
112101
113-
* **Enable or disable Analytics:** You can change the enabled state of the Analytics module at runtime by calling the `Analytics.setEnabled()` method. If you disable it, the SDK will not collect any more analytics information for the app. To re-enable it, pass `true` as a parameter in the same method.
102+
* **Enable or disable Analytics:** You can change the enabled state of the Analytics service at runtime by calling the `Analytics.setEnabled()` method. If you disable it, the SDK will not collect any more analytics information for the app. To re-enable it, pass `true` as a parameter in the same method.
114103
115104
```Java
116105
Analytics.setEnabled(false);
117106
```
118107
119-
You can also check, if the module is enabled or not using the `isEnabled()` method:
108+
You can also check if the service is enabled or not using the `isEnabled()` method:
120109
121110
```Java
122111
Analytics.isEnabled();
123112
```
124113
125114
## 5. Crashes APIs
126115
127-
Once you set up and start the Mobile Center SDK to use the Crashes module in your application, the SDK will automatically start logging any crashes in the device's local storage. When the user opens the application again, all pending crash logs will automatically be forwarded to Mobile Center and you can analyze the crash along with the stack trace on the Mobile Center portal. Refer to the section to [Start the SDK](#3-start-the-sdk) if you haven't done so already.
116+
Once you set up and start the Mobile Center SDK to use the Crashes service in your application, the SDK will automatically start logging any crashes in the device's local storage. When the user opens the application again, all pending crash logs will automatically be forwarded to Mobile Center and you can analyze the crash along with the stack trace on the Mobile Center portal. Refer to the section to [Start the SDK](#3-start-the-sdk) if you haven't done so already.
128117
129118
* **Generate a test crash:** The SDK provides you with a static API to generate a test crash for easy testing of the SDK:
130119
@@ -146,19 +135,19 @@ Once you set up and start the Mobile Center SDK to use the Crashes module in you
146135
ErrorReport crashReport = Crashes.getLastSessionCrashReport();
147136
```
148137
149-
* **Enable or disable the Crashes module:** You can disable and opt out of using the Crashes module by calling the `setEnabled()` API and the SDK will collect no crashes for your app. Use the same API to re-enable it by passing `true` as a parameter.
138+
* **Enable or disable Crashes:** You can disable and opt out of using Crashes by calling the `setEnabled()` API and the SDK will collect no crashes for your app. Use the same API to re-enable it by passing `true` as a parameter.
150139
151140
```Java
152141
Crashes.setEnabled(false);
153142
```
154143
155-
You can also check if the module is enabled or not using the `isEnabled()` method:
144+
You can also check if the service is enabled or not using the `isEnabled()` method:
156145
157146
```Java
158147
Crashes.isEnabled();
159148
```
160149
161-
* **Advanced Scenarios:** The Crashes module provides callbacks for developers to perform additional actions before and when sending crash reports to Mobile Center. This gives you added flexibility on the crash reports that will be sent.
150+
* **Advanced Scenarios:** The Crashes service provides callbacks for developers to perform additional actions before and when sending crash reports to Mobile Center. This gives you added flexibility on the crash reports that will be sent.
162151
To handle the callbacks, you must either implement all methods in the `CrashesListener` interface, or override the `AbstractCrashesListener` class and pick only the ones you're interested in.
163152
You create your own Crashes listener and assign it like this:
164153
@@ -181,7 +170,7 @@ You create your own Crashes listener and assign it like this:
181170
```
182171
183172
* **User Confirmation:** If user privacy is important to you as a developer, you might want to get user confirmation before sending a crash report to Mobile Center. The SDK exposes a callback where you can tell it to await user confirmation before sending any crash reports.
184-
Your app is then responsible for obtaining confirmation, e.g. through a dialog prompt with one of these options - "Always Send", "Send", and "Don't send". Based on the user input, you will tell the SDK and the crash will then respectively be forwarded to Mobile Center or not.
173+
Your app is then responsible for obtaining confirmation, e.g. through a dialog prompt with one of these options - "Always Send", "Send", and "Don't Send". Based on the user input, you will tell the SDK and the crash will then respectively be forwarded to Mobile Center or not.
185174
186175
```Java
187176
boolean CrashesListener.shouldAwaitUserConfirmation() {
@@ -259,7 +248,7 @@ You create your own Crashes listener and assign it like this:
259248
You only include the modules for the services you want to use. They all have a dependency on the Mobile Center module, so this will be included once you pull down the dependencies.
260249
261250
* **Debugging steps, when you can't see crash reports on the portal:**
262-
1. Make sure the SDK `start()` API is used correctly and the Crashes module is configured. Also, you need to restart the app after a crash – our SDK will forward the crash log only after it's restarted.
251+
1. Make sure the SDK `start()` API is used correctly and the Crashes service is configured. Also, you need to restart the app after a crash – our SDK will forward the crash log only after it's restarted.
263252
2. Make sure your device is connected to the internet.
264253
3. Check if the App Secret used to start the SDK matches the App Secret in the Mobile Center portal.
265254
4. Disable any other SDK that provides Crash Reporting functionality, as those might interfere with the Mobile Center SDK.
@@ -271,13 +260,4 @@ You create your own Crashes listener and assign it like this:
271260
Depending on the services you use, the following permissions are required:
272261
- Analytics, Crashes: `INTERNET`, `ACCESS_NETWORK_STATE`
273262
274-
Required permissions will automatically be merged into your app's manifest by the SDK. Where possible, the SDK will use [Run Time permissions](https://developer.android.com/training/permissions/requesting.html).
275-
276-
* **Any privacy information tracked by SDK?**
277-
278-
## 8. List of available libraries
279-
280-
Gradle Dependency | Service
281-
------------------------------------------------------------ | ---------------
282-
com.microsoft.azure.mobile:mobile-center-analytics:0.3.0 | Analytics
283-
com.microsoft.azure.mobile:mobile-center-crashes:0.3.0 | Crashes
263+
Required permissions are automatically merged into your app's manifest by the SDK.

apps/sasquatch/build.gradle

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,6 @@
44

55
evaluationDependsOn(':apps')
66

7-
/*
8-
* Not a secret, will be shared with private beta customers, git repo itself is private.
9-
* This account is read only, we use different secret credentials to publish.
10-
*/
11-
repositories {
12-
maven {
13-
url 'http://mobilecenter.bintray.com/mobilecenter'
14-
credentials {
15-
username 'mobile-center'
16-
password '9263658ba66b541c798b704723cc020cb40c6f78'
17-
}
18-
}
19-
}
20-
217
android {
228
productFlavors {
239
projectDependency {
@@ -30,7 +16,7 @@ android {
3016
}
3117

3218
dependencies {
33-
def version = "0.2.0"
19+
def version = "0.3.0"
3420
compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
3521
projectDependencyCompile project(':sdk:mobile-center-analytics')
3622
projectDependencyCompile project(':sdk:mobile-center-crashes')

apps/sasquatch/src/main/res/xml/settings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</PreferenceCategory>
2525

2626
<PreferenceCategory
27-
android:key="application_info_key"
27+
android:key="@string/application_info_key"
2828
android:title="@string/application_info_title">
2929
<Preference
3030
android:key="@string/install_id_key"

codecov.yml

Lines changed: 0 additions & 2 deletions
This file was deleted.

sdk/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ subprojects {
148148
}
149149
}
150150

151+
//noinspection GroovyMissingReturnStatement
151152
install {
152153
afterEvaluate {
153154
repositories.mavenInstaller {

sdk/mobile-center-analytics/src/main/java/com/microsoft/azure/mobile/analytics/Analytics.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public class Analytics extends AbstractMobileCenterService {
5454
private static Analytics sInstance = null;
5555

5656
/**
57-
* Log factories managed by this module.
57+
* Log factories managed by this service.
5858
*/
5959
private final Map<String, LogFactory> mFactories;
6060

@@ -103,7 +103,7 @@ static synchronized void unsetInstance() {
103103
}
104104

105105
/**
106-
* Check whether Analytics module is enabled or not.
106+
* Check whether Analytics service is enabled or not.
107107
*
108108
* @return <code>true</code> if enabled, <code>false</code> otherwise.
109109
*/
@@ -112,7 +112,7 @@ public static boolean isEnabled() {
112112
}
113113

114114
/**
115-
* Enable or disable Analytics module.
115+
* Enable or disable Analytics service.
116116
*
117117
* @param enabled <code>true</code> to enable, <code>false</code> to disable.
118118
*/
@@ -139,7 +139,7 @@ static boolean isAutoPageTrackingEnabled() {
139139
*
140140
* TODO the backend does not support that service yet, will be public method later.
141141
*
142-
* @param autoPageTrackingEnabled true to let the module track pages automatically, false otherwise (default state is true).
142+
* @param autoPageTrackingEnabled true to let the service track pages automatically, false otherwise (default state is true).
143143
*/
144144
static void setAutoPageTrackingEnabled(boolean autoPageTrackingEnabled) {
145145
getInstance().setInstanceAutoPageTrackingEnabled(autoPageTrackingEnabled);
@@ -214,6 +214,11 @@ protected String getServiceName() {
214214
return SERVICE_NAME;
215215
}
216216

217+
@Override
218+
protected String getLoggerTag() {
219+
return LOG_TAG;
220+
}
221+
217222
@Override
218223
public Map<String, LogFactory> getLogFactories() {
219224
return mFactories;

sdk/mobile-center-crashes/src/androidTest/java/com/microsoft/azure/mobile/crashes/CrashesAndroidTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public void wrapperSdkOverrideLog() throws InterruptedException {
191191
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
192192
ManagedErrorLog errorLog = (ManagedErrorLog) invocationOnMock.getArguments()[0];
193193
errorLog.setErrorThreadName("ReplacedErrorThreadName");
194-
Crashes.getInstance().saveWrapperSdkErrorLog(errorLog);
194+
WrapperSdkExceptionManager.saveWrapperSdkErrorLog(errorLog);
195195
return null;
196196
}
197197
}).when(wrapperSdkListener).onCrashCaptured(notNull(ManagedErrorLog.class));

0 commit comments

Comments
 (0)