Skip to content

Commit 34e0e5b

Browse files
authored
🤝 Merge pull request #18 from Instabug/fix/8.0.6
🐛 fix ClassNotFoundException when using reportJSException since v8.0.4
2 parents e388468 + 8c347e0 commit 34e0e5b

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ public void setCrashReportingEnabled(boolean isEnabled) {
504504
private void sendJSCrashByReflection(String exceptionObject, boolean isHandled) {
505505
try {
506506
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);
508508
if (method != null) {
509509
method.invoke(null, newJSONObject, isHandled);
510510
}
@@ -520,12 +520,22 @@ private void sendJSCrashByReflection(String exceptionObject, boolean isHandled)
520520

521521
}
522522

523-
public static Method getMethod(Class clazz, String methodName) {
523+
private static Method getMethod(Class clazz, String methodName, Class... parameterType) {
524524
final Method[] methods = clazz.getDeclaredMethods();
525+
525526
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+
}
529539
}
530540
}
531541
return null;

0 commit comments

Comments
 (0)