Skip to content

Commit 499595b

Browse files
mdvaccafacebook-github-bot
authored andcommitted
Add IgnoreStringLiterals in DefaultDevSupportManagerFactory class
Summary: Adding IgnoreStringLiterals in DefaultDevSupportManagerFactory class to prevent proguard to keep the BridgeDevSupportManager class changelog: [internal] internal Reviewed By: alanleedev Differential Revision: D72090836
1 parent 8d28b57 commit 499595b

1 file changed

Lines changed: 5 additions & 14 deletions

File tree

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DefaultDevSupportManagerFactory.kt

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ import com.facebook.react.devsupport.interfaces.DevSupportManager
1616
import com.facebook.react.devsupport.interfaces.PausedInDebuggerOverlayManager
1717
import com.facebook.react.devsupport.interfaces.RedBoxHandler
1818
import com.facebook.react.packagerconnection.RequestHandler
19+
import com.facebook.redex.annotations.IgnoreStringLiterals
1920

2021
/**
2122
* A simple factory that creates instances of [DevSupportManager] implementations. Uses reflection
2223
* to create BridgeDevSupportManager if it exists. This allows ProGuard to strip that class and its
2324
* dependencies in release builds. If the class isn't found, [PerftestDevSupportManager] is returned
2425
* instead.
2526
*/
27+
@IgnoreStringLiterals
2628
internal class DefaultDevSupportManagerFactory : DevSupportManagerFactory {
2729

2830
override fun create(
@@ -47,15 +49,9 @@ internal class DefaultDevSupportManagerFactory : DevSupportManagerFactory {
4749
// trying to return the full support DevSupportManager and if it fails, then just
4850
// return PerftestDevSupportManager.
4951

50-
// ProGuard is surprisingly smart in this case and will keep a class if it detects a call
51-
// to
52-
// Class.forName() with a static string. So instead we generate a quasi-dynamic string to
53-
// confuse it.
54-
val className =
55-
StringBuilder(DEVSUPPORT_IMPL_PACKAGE)
56-
.append(".")
57-
.append(DEVSUPPORT_IMPL_CLASS)
58-
.toString()
52+
// @IgnoreStringLiterals annotation is used to enable ProGuard to strip out the
53+
// BridgeDevSupportManager class
54+
val className = "com.facebook.react.devsupport.BridgeDevSupportManager"
5955
val devSupportManagerClass = Class.forName(className)
6056
val constructor =
6157
devSupportManagerClass.getConstructor(
@@ -121,9 +117,4 @@ internal class DefaultDevSupportManagerFactory : DevSupportManagerFactory {
121117
devLoadingViewManager,
122118
pausedInDebuggerOverlayManager)
123119
}
124-
125-
private companion object {
126-
private const val DEVSUPPORT_IMPL_PACKAGE = "com.facebook.react.devsupport"
127-
private const val DEVSUPPORT_IMPL_CLASS = "BridgeDevSupportManager"
128-
}
129120
}

0 commit comments

Comments
 (0)