React-native-track-player: Integration with expokit based projects

Created on 9 Nov 2017  路  12Comments  路  Source: react-native-kit/react-native-track-player

I have an expokit based project with which I am trying to integrate this plugin. It uses cocoapods to handle dependencies on iOS.

I have linked the project and as mentioned here I have added the header search path to RNTrackPlayer project as ../../../ios/Pods/Headers/Public/React/

Now I'm running into Overriding method with selector 'constantsToExport' has incompatible type '() -> [String : Any]' from RNTrackPlayer.swift. I have tried the solution from https://github.com/react-native-kit/react-native-track-player/issues/27 but still get the error. I'm using Xcode Version 9.2 beta (9C34b).

On Android there's a namespace clash, /trackplayer_integration/node_modules/react-native-track-player/android/src/main/java/guichaguri/trackplayer/metadata/components/ArtworkLoader.java:45: error: incompatible types: expolib_v1.okhttp3.OkHttpClient cannot be converted to okhttp3.OkHttpClient OkHttpClient client = OkHttpClientProvider.getOkHttpClient();

Let me know if I should raise this issue with the expo team. I am not sure where I should raise it.

Here's a repo which can reproduce the iOS and Android issues https://github.com/peterlazar1993/trackplayer_integration

Android Bug

All 12 comments

For Android, it's an issue with Expo itself.
Expo changed OkHttp's library package from okhttp3.OkHttpClient to expolib_v1.okhttp3.OkHttpClient, which breaks any package that uses it. I don't know why they have changed that, but I do know it's not only react-native-track-player that crashes on Expo. (See https://github.com/wkh237/react-native-fetch-blob/issues/549).

For iOS, which version of React Native are you currently using?

I'll raise an issue with expo regarding okhttp.
I'm using expo 22, which is based on RN 0.49

@dcvz can you take a look into the iOS error?

Ohh so @Guichaguri we have to detach from Expo ?
@peterlazar1993 Are you able to use this ?
Note - SDK 23 is been released few hours ago

You'll definitely have to detach from expo. But I can't get this integrated with the detached project too. Have not tried with sdk 23 though.

Cool

@peterlazar1993 does the same issue with OkHttpClient happens on a detached project?

@Guichaguri The iOS issue seems to be fixed in the dev branch https://github.com/react-native-kit/react-native-track-player/commit/079d70f98a32e95bc402b95e0b46fa426ed9bb7f#diff-44c74236a1adc81d43903a61beab25ea
I am able to successfully compile play a sample audio track. I'll document exactly what I did to get it working.

The OkHttpClient issue happens on detached build. FYI detached is not the same as a clean RN project. Detaching will continue to use expokit, enabling the use of Expo SDKs.

Some more updates regarding android. I commented out the OkHttp calls. They were used to download the album art, which I am not interested in.

Now the compilation proceeds and throws java.lang.NoSuchMethodError: No static method zzh(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String; in class Lcom/google/android/gms/common/internal/zzab; or its super classes (declaration of 'com.google.android.gms.common.internal.zzab' appears in /data/app/com.test.trackplayer-1/split_lib_dependencies_apk.apk:classes52.dex)

from some googling, figured out that this a play services version collision issue. So bumped up the cast services version to 9.8 at this line

Now the error is regarding not being able to start the player service java.lang.RuntimeException: Unable to start service guichaguri.trackplayer.logic.services.PlayerTask@6d7f422 with Intent { cmp=com.test.trackplayer/guichaguri.trackplayer.logic.services.PlayerTask (has extras) }: java.lang.ClassCastException: com.test.trackplayer.MainApplication cannot be cast to com.facebook.react.ReactApplication

I have reproduced the error in this repo https://github.com/peterlazar1993/trackplayer_integration

@peterlazar1993 That's a problem with the Cast SDK. You can't really bump its version, you have to downgrade other Play Services SDKs, unfortunatelly

We have plans to redo the cast integration, splitting it in another addon module.

I removed the cast dependency from this project, I'll be rebuilding that in react-native-track-casting.

I dropped Expo from my project and the TrackPlayer works great on both iOS and Android.

Was this page helpful?
0 / 5 - 0 ratings