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

Unhandled Exception: PlatformException #19

Closed
Zazo032 opened this issue Feb 14, 2020 · 6 comments
Closed

Unhandled Exception: PlatformException #19

Zazo032 opened this issue Feb 14, 2020 · 6 comments
Labels
help wanted Extra attention is needed

Comments

@Zazo032
Copy link

Zazo032 commented Feb 14, 2020

Plugin version: 0.5.1
Flutter version: 1.15.4
Kotlin version: 1.3.61

We're sometimes seeing in the logs the following unhandled exception:

E/flutter (11731): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(error, Unsupported value type: class java.util.ArrayList (Kotlin reflection is not available), null)
E/flutter (11731): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569)
E/flutter (11731): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156)
E/flutter (11731): <asynchronous suspension>
E/flutter (11731): #2 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:329)
E/flutter (11731): #3 FacebookAppEvents.logEvent (package:facebook_app_events/facebook_app_events.dart:68)
** ellided info **
@DennisAlund
Copy link
Member

Please provide some context on what values that you tried to pass into the functions. Could you provide the code part which causes this error to occur and also the values which you passed to the logEvent

@DennisAlund
Copy link
Member

Closing due to inactivity

@Zazo032
Copy link
Author

Zazo032 commented Aug 31, 2020

@DennisAlund Hi, this happens when this Map is provided to the parameters param, in the logEvent function:

final Map<String, dynamic> _params = <String, dynamic>{
  'content_category': 'Alicante',
  'content_name': 'Viena',
  'content_ids': <String>['alcvie'],
  'content_type': 'Alicante-Viena-Alicante',
};

To give some context, this is the method that throws the exception:

private fun createBundleFromMap(parameterMap: Map<String, Any>?): Bundle? {
if (parameterMap == null) {
return null
}
val bundle = Bundle()
for (jsonParam in parameterMap.entries) {
val value = jsonParam.value
val key = jsonParam.key
if (value is String) {
bundle.putString(key, value as String)
} else if (value is Int) {
bundle.putInt(key, value as Int)
} else if (value is Long) {
bundle.putLong(key, value as Long)
} else if (value is Double) {
bundle.putDouble(key, value as Double)
} else if (value is Boolean) {
bundle.putBoolean(key, value as Boolean)
} else if (value is Map<*, *>) {
val nestedBundle = createBundleFromMap(value as Map<String, Any>)
bundle.putBundle(key, nestedBundle as Bundle)
} else {
throw IllegalArgumentException(
"Unsupported value type: " + value.javaClass.kotlin)
}
}
return bundle
}

java.lang.IllegalArgumentException: Unsupported value type: class java.util.ArrayList (Kotlin reflection is not available)
E/MethodChannel#flutter.oddbit.id/facebook_app_events(16471): 	at id.oddbit.flutter.facebook_app_events.FacebookAppEventsPlugin.createBundleFromMap(FacebookAppEventsPlugin.kt:176)

There's no if case for ArrayList.

Could you reopen this issue?

@DennisAlund DennisAlund reopened this Oct 15, 2020
@DennisAlund DennisAlund added the help wanted Extra attention is needed label Nov 17, 2020
@olegys
Copy link

olegys commented Dec 22, 2020

Same error on array:

_facebookAppEvents.logEvent(
  name: 'AddToCart',
  valueToSum: _price,
  parameters: {
    'value': _price,
    'currency': 'UAH',
    'content_type': 'product',
    'content_ids': [product.id.toString()],
    'content_name': product.name,
    'content_category': product.type,
  },
); 

@olegys
Copy link

olegys commented Dec 23, 2020

Same error on array:

_facebookAppEvents.logEvent(
  name: 'AddToCart',
  valueToSum: _price,
  parameters: {
    'value': _price,
    'currency': 'UAH',
    'content_type': 'product',
    'content_ids': [product.id.toString()],
    'content_name': product.name,
    'content_category': product.type,
  },
); 

found a solution to this problem, can be sent by string: "["1234","5678"]"

@DennisAlund
Copy link
Member

I think this falls under developer responsibility in case it's a generic event, since it will depend on the parameter and what specifications of the content that is for that parameter type.

Please see examples where the JSON encoding has been built into the wrapper functions for some event logging

paramNameContent: content != null ? json.encode(content) : null,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants