diff --git a/CHANGELOG.md b/CHANGELOG.md index 42d2a1960..317e9a7ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ * Adds BugReporting.setFloatingButtonEdge API * Supports starting SDK from Dart only. +* Fixes an issue with Android screenshots being black on release mode on SDK v10.13.0 ## v10.13.0 (2022-03-31) diff --git a/android/src/main/java/com/instabug/instabugflutter/InstabugFlutterPlugin.java b/android/src/main/java/com/instabug/instabugflutter/InstabugFlutterPlugin.java index e5c6ac8d6..f855a2164 100644 --- a/android/src/main/java/com/instabug/instabugflutter/InstabugFlutterPlugin.java +++ b/android/src/main/java/com/instabug/instabugflutter/InstabugFlutterPlugin.java @@ -9,6 +9,7 @@ import android.util.Log; import androidx.annotation.NonNull; +import androidx.annotation.VisibleForTesting; import com.instabug.apm.APM; import com.instabug.apm.model.ExecutionTrace; @@ -165,7 +166,7 @@ public void startWithToken(String token, ArrayList invocationEvents) { .setInvocationEvents(invocationEventsArray) .build(); - enableScreenShotByMediaProjection(); + enableScreenShotByMediaProjection(true); } /** @@ -429,20 +430,9 @@ public void setValue(String value, String forStringWithKey) { /** * Enables taking screenshots by media projection. */ - private void enableScreenShotByMediaProjection() { - try { - Method method = getMethod(Class.forName("com.instabug.bug.BugReporting"), - "setScreenshotByMediaProjectionEnabled", boolean.class); - if (method != null) { - method.invoke(null, true); - } - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } + @VisibleForTesting + public static void enableScreenShotByMediaProjection(boolean isScreenshotByMediaProjectionEnabled) { + BugReporting.setScreenshotByMediaProjectionEnabled(isScreenshotByMediaProjectionEnabled); } /** diff --git a/example/android/app/src/androidTest/java/com/example/InstabugSample/InvokeInstabugUITest.java b/example/android/app/src/androidTest/java/com/example/InstabugSample/InvokeInstabugUITest.java index 82aa5d749..bbee360a3 100644 --- a/example/android/app/src/androidTest/java/com/example/InstabugSample/InvokeInstabugUITest.java +++ b/example/android/app/src/androidTest/java/com/example/InstabugSample/InvokeInstabugUITest.java @@ -16,6 +16,8 @@ import static androidx.test.espresso.matcher.ViewMatchers.withResourceName; import static androidx.test.espresso.matcher.ViewMatchers.withText; +import com.instabug.instabugflutter.InstabugFlutterPlugin; + @RunWith(AndroidJUnit4.class) public class InvokeInstabugUITest { @@ -37,18 +39,7 @@ public void ensureInstabugInvocati1on() throws InterruptedException { } private void disableScreenShotByMediaProjection() { - try { - Method method = getMethod(Class.forName("com.instabug.bug.BugReporting"), "setScreenshotByMediaProjectionEnabled", boolean.class); - if (method != null) { - method.invoke(null, false); - } - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } + InstabugFlutterPlugin.enableScreenShotByMediaProjection(false); } public static Method getMethod(Class clazz, String methodName, Class... parameterType) {