@@ -504,7 +504,7 @@ public void setCrashReportingEnabled(boolean isEnabled) {
504
504
private void sendJSCrashByReflection (String exceptionObject , boolean isHandled ) {
505
505
try {
506
506
JSONObject newJSONObject = new JSONObject (exceptionObject );
507
- Method method = getMethod (Class .forName ("com.instabug.crash.InstabugCrash " ), "reportException" );
507
+ Method method = getMethod (Class .forName ("com.instabug.crash.CrashReporting " ), "reportException" , JSONObject . class , boolean . class );
508
508
if (method != null ) {
509
509
method .invoke (null , newJSONObject , isHandled );
510
510
}
@@ -520,12 +520,22 @@ private void sendJSCrashByReflection(String exceptionObject, boolean isHandled)
520
520
521
521
}
522
522
523
- public static Method getMethod (Class clazz , String methodName ) {
523
+ private static Method getMethod (Class clazz , String methodName , Class ... parameterType ) {
524
524
final Method [] methods = clazz .getDeclaredMethods ();
525
+
525
526
for (Method method : methods ) {
526
- if (method .getName ().equals (methodName )) {
527
- method .setAccessible (true );
528
- return method ;
527
+ if (method .getName ().equals (methodName ) && method .getParameterTypes ().length ==
528
+ parameterType .length ) {
529
+ for (int i = 0 ; i < 2 ; i ++) {
530
+ if (method .getParameterTypes ()[i ] == parameterType [i ]) {
531
+ if (i == method .getParameterTypes ().length - 1 ) {
532
+ method .setAccessible (true );
533
+ return method ;
534
+ }
535
+ } else {
536
+ break ;
537
+ }
538
+ }
529
539
}
530
540
}
531
541
return null ;
0 commit comments