Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Android NullPointerException crash #354

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,9 @@ public void onSuccess() {
uiThreadHandler.post(new Runnable() {
@Override
public void run() {
mMethodChannel.invokeMethod("onSuccess", null);
if (mMethodChannel != null) {
mMethodChannel.invokeMethod("onSuccess", null);
}
}
});
}
Expand All @@ -396,10 +398,12 @@ public void onError(final int errorCode, final String errorMessage) {
uiThreadHandler.post(new Runnable() {
@Override
public void run() {
HashMap<String, Object> errorDetails = new HashMap<>();
errorDetails.put("errorCode", errorCode);
errorDetails.put("errorMessage", errorMessage);
mMethodChannel.invokeMethod("onError", errorDetails);
if (mMethodChannel != null) {
HashMap<String, Object> errorDetails = new HashMap<>();
errorDetails.put("errorCode", errorCode);
errorDetails.put("errorMessage", errorMessage);
mMethodChannel.invokeMethod("onError", errorDetails);
}
}
});
}
Expand Down Expand Up @@ -963,8 +967,8 @@ private void logAdRevenue(MethodCall call, Result result) {
try {
String monetizationNetwork = requireNonNullArgument(call, "monetizationNetwork");
String currencyIso4217Code = requireNonNullArgument(call, "currencyIso4217Code");
double revenue = requireNonNullArgument(call,"revenue");
String mediationNetworkString = requireNonNullArgument(call,"mediationNetwork");
double revenue = requireNonNullArgument(call, "revenue");
String mediationNetworkString = requireNonNullArgument(call, "mediationNetwork");

MediationNetwork mediationNetwork = MediationNetwork.valueOf(mediationNetworkString.toUpperCase());

Expand All @@ -984,8 +988,7 @@ private void logAdRevenue(MethodCall call, Result result) {
} catch (IllegalArgumentException e) {
// The IllegalArgumentException could come from either requireNonNullArgument or valueOf methods.
result.error("INVALID_ARGUMENT_PROVIDED", e.getMessage(), null);
}
catch (Throwable t) {
} catch (Throwable t) {
result.error("UNEXPECTED_ERROR", "[logAdRevenue]: An unexpected error occurred: " + t.getMessage(), null);
Log.e("AppsFlyer", "Unexpected exception occurred: [logAdRevenue]", t);
}
Expand Down