From 2a7874501040b430d09ac4f795e4599bdb730a18 Mon Sep 17 00:00:00 2001 From: Victor Garcia Date: Mon, 26 Apr 2021 12:00:51 +0200 Subject: [PATCH 1/2] [MASTER-DEV] Docs: improve debugging section --- README.md | 4 ++-- docs/content/developer/debugging.md | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e64161caa9..aba8e1a3b5 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Main goals: ## Documentation -Developer-oriented documentation can be found in [Documentation section](https://docs.dhis2.org/master/en/dhis2_android_sdk_developer_guide/about-this-guide.html) in DHIS2 web. It is intended to be used by developers. +Developer-oriented documentation can be found in [Documentation section](https://docs.dhis2.org/en/develop/developing-with-the-android-sdk/about-this-guide.html) in DHIS2 web. It is intended to be used by developers. ## Examples @@ -24,4 +24,4 @@ Code examples can be found in the [Android Skeleton app](https://github.com/dhis Community support can be found in [Android SDK Development](https://community.dhis2.org/c/development/sdk-android-development) category in the community portal. Any feedback on the SDK will be highly appreciated. -To report bugs or request new features, there is project in DHIS2 Jira named [ANDROSDK](https://jira.dhis2.org/projects/ANDROSDK). Please do not hesitate to create an issue with your request. +To report bugs or request new features, there is project in DHIS2 Jira named [ANDROSDK](https://jira.dhis2.org/projects/ANDROSDK/issues). Please do not hesitate to create an issue with your request. diff --git a/docs/content/developer/debugging.md b/docs/content/developer/debugging.md index 08233a5467..c936dfdf92 100644 --- a/docs/content/developer/debugging.md +++ b/docs/content/developer/debugging.md @@ -12,6 +12,7 @@ Specially relevant plugins to debug the SDK: - Database: see table content and perform custom SQL queries Steps to install it and configure it: + 1. Ensure you have the Android SDK installed (you probably will if you are planning to debug an Android app) 2. Download Flipper from [its website](https://fbflipper.com/) 3. Modify your build.gradle to install Flipper dependencies. From e07c46df1eb601aa3b49c50e4e91f228feb8347c Mon Sep 17 00:00:00 2001 From: Victor Garcia Date: Mon, 26 Apr 2021 12:05:11 +0200 Subject: [PATCH 2/2] [MASTER-DEV] Docs: ident code block in debugging --- docs/content/developer/debugging.md | 132 ++++++++++++++-------------- 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/docs/content/developer/debugging.md b/docs/content/developer/debugging.md index c936dfdf92..95a3701f3c 100644 --- a/docs/content/developer/debugging.md +++ b/docs/content/developer/debugging.md @@ -17,90 +17,90 @@ Steps to install it and configure it: 2. Download Flipper from [its website](https://fbflipper.com/) 3. Modify your build.gradle to install Flipper dependencies. -```gradle -dependencies { - ... - debugImplementation "com.facebook.flipper:flipper:0.83.0" - debugImplementation "com.facebook.soloader:soloader:0.10.1" - debugImplementation ("com.facebook.flipper:flipper-network-plugin:0.83.0") { - exclude group: 'com.squareup.okhttp3' - } + ```gradle + dependencies { + ... + debugImplementation "com.facebook.flipper:flipper:0.83.0" + debugImplementation "com.facebook.soloader:soloader:0.10.1" + debugImplementation ("com.facebook.flipper:flipper-network-plugin:0.83.0") { + exclude group: 'com.squareup.okhttp3' + } - releaseImplementation "com.facebook.flipper:flipper-noop:0.83.0" -} -``` + releaseImplementation "com.facebook.flipper:flipper-noop:0.83.0" + } + ``` 4. DHIS2 Android SDK includes a no-op version of Flipper in the release version. It should be excluded to avoid duplicated classes. -```gradle -dependencies { - ... - implementation ("org.hisp.dhis:android-core:x.x.x") { - exclude group: 'com.facebook.flipper' + ```gradle + dependencies { + ... + implementation ("org.hisp.dhis:android-core:x.x.x") { + exclude group: 'com.facebook.flipper' + } } -} -``` + ``` 5. Add the diagnostic activity to the Android Manifest: -```xml - -``` + ```xml + + ``` 6. It is recommended to create a helper class to initialize Flipper and create the network interceptor: -```java -import android.content.Context; - -import com.example.android.androidskeletonapp.BuildConfig; -import com.facebook.flipper.android.AndroidFlipperClient; -import com.facebook.flipper.android.utils.FlipperUtils; -import com.facebook.flipper.core.FlipperClient; -import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin; -import com.facebook.flipper.plugins.inspector.DescriptorMapping; -import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin; -import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor; -import com.facebook.flipper.plugins.network.NetworkFlipperPlugin; -import com.facebook.soloader.SoLoader; - -import okhttp3.Interceptor; - -public class FlipperManager { - - public static Interceptor setUp(Context appContext) { - if (BuildConfig.DEBUG && FlipperUtils.shouldEnableFlipper(appContext)) { - NetworkFlipperPlugin networkPlugin = new NetworkFlipperPlugin(); - SoLoader.init(appContext, false); - FlipperClient client = AndroidFlipperClient.getInstance(appContext); - client.addPlugin(networkPlugin); - client.addPlugin(new DatabasesFlipperPlugin(appContext)); - client.addPlugin(new InspectorFlipperPlugin(appContext, DescriptorMapping.withDefaults())); - client.start(); - return new FlipperOkhttpInterceptor(networkPlugin); - } else { - return null; + ```java + import android.content.Context; + + import com.example.android.androidskeletonapp.BuildConfig; + import com.facebook.flipper.android.AndroidFlipperClient; + import com.facebook.flipper.android.utils.FlipperUtils; + import com.facebook.flipper.core.FlipperClient; + import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin; + import com.facebook.flipper.plugins.inspector.DescriptorMapping; + import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin; + import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor; + import com.facebook.flipper.plugins.network.NetworkFlipperPlugin; + import com.facebook.soloader.SoLoader; + + import okhttp3.Interceptor; + + public class FlipperManager { + + public static Interceptor setUp(Context appContext) { + if (BuildConfig.DEBUG && FlipperUtils.shouldEnableFlipper(appContext)) { + NetworkFlipperPlugin networkPlugin = new NetworkFlipperPlugin(); + SoLoader.init(appContext, false); + FlipperClient client = AndroidFlipperClient.getInstance(appContext); + client.addPlugin(networkPlugin); + client.addPlugin(new DatabasesFlipperPlugin(appContext)); + client.addPlugin(new InspectorFlipperPlugin(appContext, DescriptorMapping.withDefaults())); + client.start(); + return new FlipperOkhttpInterceptor(networkPlugin); + } else { + return null; + } } } -} -``` + ``` 7. Set up the plugins while configuring the SDK: -```java - // This will be null if not debug mode to make sure your data is safe - Interceptor flipperInterceptor = FlipperManager.setUp(context.getApplicationContext()); + ```java + // This will be null if not debug mode to make sure your data is safe + Interceptor flipperInterceptor = FlipperManager.setUp(context.getApplicationContext()); - List networkInterceptors = new ArrayList<>(); - if (flipperInterceptor != null) { - networkInterceptors.add(flipperInterceptor); - } + List networkInterceptors = new ArrayList<>(); + if (flipperInterceptor != null) { + networkInterceptors.add(flipperInterceptor); + } - return D2Configuration.builder() - ... - .networkInterceptors(networkInterceptors) - .build(); -``` + return D2Configuration.builder() + ... + .networkInterceptors(networkInterceptors) + .build(); + ``` If you want to use any other Flipper plugins to debug other aspects of the app, we recommend you to go through [the documentation](https://fbflipper.com/docs/getting-started/android-native).