react-native-spotify-remote icon indicating copy to clipboard operation
react-native-spotify-remote copied to clipboard

Android Build Error: incompatible types: ReadableMap cannot be converted to WritableMap

Open stefan-applantis opened this issue 4 years ago • 11 comments

Building Android fails with errors

warning: unknown enum constant Include.NON_NULL
  reason: class file for com.fasterxml.jackson.annotation.JsonInclude$Include not found
/node_modules/react-native-spotify-remote/android/src/main/java/com/reactlibrary/Convert.java:42: error: incompatible types: ReadableMap cannot be converted to WritableMap
            array.pushMap(Convert.toMap(item));
                                       ^
/node_modules/react-native-spotify-remote/android/src/main/java/com/reactlibrary/Convert.java:105: error: incompatible types: ReadableMap cannot be converted to WritableMap
        map.putMap("artist", Convert.toMap(track.artist));
                                          ^
/node_modules/react-native-spotify-remote/android/src/main/java/com/reactlibrary/Convert.java:106: error: incompatible types: ReadableMap cannot be converted to WritableMap
        map.putMap("album", Convert.toMap(track.album));
                                         ^
/node_modules/react-native-spotify-remote/android/src/main/java/com/reactlibrary/Convert.java:138: error: incompatible types: ReadableMap cannot be converted to WritableMap
        map.putMap("playbackOptions", Convert.toMap(playerState.playbackOptions));
                                                   ^
/node_modules/react-native-spotify-remote/android/src/main/java/com/reactlibrary/Convert.java:139: error: incompatible types: ReadableMap cannot be converted to WritableMap
        map.putMap("playbackRestrictions", Convert.toMap(playerState.playbackRestrictions));
                                                        ^
/node_modules/react-native-spotify-remote/android/src/main/java/com/reactlibrary/Convert.java:140: error: incompatible types: ReadableMap cannot be converted to WritableMap
        map.putMap("track", Convert.toMap(playerState.track));

stefan-applantis avatar Aug 18 '20 06:08 stefan-applantis

This seems to have been caused by the fact that we were using [email protected]. This worked fine for iOS but apparently not for Android. Upgrading to [email protected] (the listed peer-dependency version) resolved the compilation errors.

ian-playside avatar Aug 19 '20 05:08 ian-playside

Ah great to know. I must have used some react-specific feature in the conversion functions. I'll mark this as a bug so I can remember to take a look at it. Glad that upgrading RN solved the problem.

cjam avatar Aug 19 '20 12:08 cjam

Just a note for myself.

I recently set the peer dependency to >0.60 so I'll likely need to change that back to >0.61

cjam avatar Dec 16 '20 17:12 cjam

Hey @cjam

We are trying to run the latest version on RN 0.60.6 and running into this build issue. Do you perhaps know which version of the lib we can downgrade to or is our only hope to upgrade to RN > 0.61?

reinhardholl avatar Feb 23 '21 12:02 reinhardholl

Hey @reinhardholl , good question. Are you jettifying your project? (i.e using AndroidX). I seem to recall running into some weirdness like this until I started running the jetify on install.

cjam avatar Mar 03 '21 18:03 cjam

@cjam yup we are. I will double check today and get back with some more feedback.

reinhardholl avatar Mar 05 '21 07:03 reinhardholl

Hey @cjam; We are definitely using Jettifier but unfortunately we can't get it building on RN 0.60.6. Any tips/suggestions from your side or is upgrading our only option?

Thanks!

reinhardholl avatar Mar 16 '21 09:03 reinhardholl

I'm pretty swamped these days but if I can find some time I'll try to reproduce the issue you are having.

cjam avatar Mar 16 '21 14:03 cjam

Upgrading to React Native 0.61.5 solved it for us. :)

reinhardholl avatar Apr 09 '21 19:04 reinhardholl

That's great news. There must have been some breaking change in there that I missed. I'm not sure if there is anything I can do at this point to fix the issue for those < 0.61.5 perhaps I just need to add something to the docs about compatability.

cjam avatar Apr 15 '21 14:04 cjam

@cjam yeah docs is a good start :) I tried having a look but we needed to upgrade anyway so we opted to just push through.

reinhardholl avatar Apr 20 '21 11:04 reinhardholl