From d3b2ac3a84caa0971bb166c58942f173702c7c45 Mon Sep 17 00:00:00 2001 From: Emily Janzer Date: Fri, 31 Jan 2020 14:02:09 -0800 Subject: [PATCH] Add @DoNotStrip to method called from cpp in bridgeless mode Summary: I hit a crash when testing bridgeless mode in a release build: Error: Exception in HostFunction: java.lang.NoSuchMethodError: no non-static method "Lcom/facebook/react/modules/core/JavaTimerManager;.createTimer(IJZ)V" It turns out that `JavaTimerManager.createTimer()` is getting stripped from release builds because it's not referenced in Java at all. Adding `DoNotStrip` annotation to keep it around. The other methods in JavaTimerManager don't need this because they're referenced by TimingModule - this is the only method that's only used directly from C++ by bridgeless mode. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D19655519 fbshipit-source-id: 8b9862475986bb84b12d81f73f677cc2e4860c67 --- .../java/com/facebook/react/modules/core/JavaTimerManager.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/core/JavaTimerManager.java b/ReactAndroid/src/main/java/com/facebook/react/modules/core/JavaTimerManager.java index 37fc90ff333..9ca8f41db9a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/core/JavaTimerManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/core/JavaTimerManager.java @@ -9,6 +9,7 @@ package com.facebook.react.modules.core; import android.util.SparseArray; import androidx.annotation.Nullable; +import com.facebook.proguard.annotations.DoNotStrip; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.UiThreadUtil; @@ -293,6 +294,7 @@ public class JavaTimerManager { * @param delay The time in ms before the callback should be invoked. * @param repeat Whether the timer should be repeated (used for setInterval). */ + @DoNotStrip public void createTimer(final int callbackID, final long delay, final boolean repeat) { long initialTargetTime = SystemClock.nanoTime() / 1000000 + delay; Timer timer = new Timer(callbackID, initialTargetTime, (int) delay, repeat);