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

AdMob Api errror: type 'List<dynamic>' is not a subtype of type 'Map<String, dynamic>' #183

Closed
chuongdevJC opened this issue Mar 3, 2021 · 15 comments

Comments

@chuongdevJC
Copy link

chuongdevJC commented Mar 3, 2021

I faced 'type 'List' is not a subtype of type 'Map<String, dynamic>' error when i try to call 'adMob.accounts.networkReport.generate()'
image
Please help! thanks.

Google-internal issue http://b/173703913

@kevmoo
Copy link
Collaborator

kevmoo commented Mar 8, 2021

Which version of googleapis are you using?

@chuongdevJC
Copy link
Author

chuongdevJC commented Mar 9, 2021

googleapis

Hi! I'm using version googleapis 1.0.0.

@kevmoo kevmoo removed the needs-info label Mar 9, 2021
@kevmoo
Copy link
Collaborator

kevmoo commented Mar 9, 2021

Sadly, we're limited to what we get from the discovery document

https://github.com/dart-lang/googleapis/blob/3b42c7826f0d07dbc81673c50b54c2141cefb3a0/discovery/googleapis/admob__v1.json#L283-L301

We need to file an issue with the AdMob team.

@kevmoo kevmoo added the blocked label Mar 9, 2021
@chuongdevJC
Copy link
Author

Thanks! Hope it will be resolved quickly

@kevmoo
Copy link
Collaborator

kevmoo commented Mar 9, 2021

Remember, you could always fork this repo and hack at this function. If you're adventurous, you don't have to wait!

@chuongdevJC
Copy link
Author

chuongdevJC commented Mar 9, 2021

@kevmoo I thought of that. I debugged somehow 'List<core.dynamic> cast to Map<core.String, core.dynamic>' is not work but if I try to cast without library core it's work.

@SercanKaya0
Copy link

@kevmoo I thought of that. I debugged somehow 'List<core.dynamic> cast to Map<core.String, core.dynamic>' is not work but if I try to cast without library core it's work.

How to Fix ?

@kevmoo
Copy link
Collaborator

kevmoo commented Sep 22, 2021

If you makes you feel better, Object-C is having the same problem - google/google-api-objectivec-client-for-rest#447

@kevmoo
Copy link
Collaborator

kevmoo commented Sep 22, 2021

See also googleapis/google-api-ruby-client#902

@kevmoo
Copy link
Collaborator

kevmoo commented Sep 22, 2021

Google internal issue: http://b/173703913

We're one of at least 3 APIs having the same issue. The short-term workaround is to copy the function that is erroring out and to fix the implementation.

I don't currently have the ability to easily hack the output classes here, but I'll look into it.

@kevmoo kevmoo self-assigned this Sep 22, 2021
@SercanKaya0
Copy link

try {
if (response.data is List) {
var list = response.data as List;
var dataList = List.from(
list.map((item) => responseType.fromJson(item)).toList()) as K;
return dataList;
} else {
var data = responseType.fromJson(response.data) as K;
return data;
}

This is a method I use in my own responses, maybe it will work for you.

@kevmoo
Copy link
Collaborator

kevmoo commented Sep 22, 2021

@SercanKaya0 – yup. That'll work.

at the moment, try NOT to do one-off hacks to the generated code. Because then I need to manage the output. It's complicated.

@kevmoo
Copy link
Collaborator

kevmoo commented Sep 30, 2021

Fixed in 22d7103 – shipped in the latest package:_discoveryapis_common

@kevmoo kevmoo closed this as completed Sep 30, 2021
@kevmoo
Copy link
Collaborator

kevmoo commented Oct 17, 2021

I fixed the error reporting, but not the actual issue. Reopening!

@kevmoo
Copy link
Collaborator

kevmoo commented Nov 1, 2021

Fix is now out in v7

mobiledev34 added a commit to mobiledev34/googleapis.dart that referenced this issue Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants