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

Method return type must not include a type variable or wildcard #22

Closed
kikebodi opened this issue Aug 15, 2018 · 6 comments
Closed

Method return type must not include a type variable or wildcard #22

kikebodi opened this issue Aug 15, 2018 · 6 comments

Comments

@kikebodi
Copy link

kikebodi commented Aug 15, 2018

I'm getting the following error:
IllegalArgumentException: Method return type must not include a type variable or wildcard: io.reactivex.Flowable<com.tinder.scarlet.WebSocket$Event$OnConnectionOpened<?>>
at
@Receive fun observeOnConnectionOpenedEvent(): Flowable<WebSocket.Event.OnConnectionOpened<*>>

fun <T> create(service: Class<T>): T { val clientBuilder = OkHttpClient.Builder() clientBuilder.addInterceptor(AuthInterceptor() val scarlet = Scarlet.Builder() .webSocketFactory(clientBuilder.build().newWebSocketFactory(ApiEndPoint.WEBSOCKET)) .addMessageAdapterFactory(GsonMessageAdapter.Factory()) .addStreamAdapterFactory(RxJava2StreamAdapterFactory()) .build() return scarlet.create(service) }

val websocketApi = BaseScarletBuilder.create(WebsocketApi::class.java)

Is this the way we are suppose to use the lib?

@7va
Copy link

7va commented Aug 20, 2018

Same thing

@7va
Copy link

7va commented Aug 20, 2018

I have fit it by replace
@receive fun observeOnConnectionOpenedEvent(): Flowable<WebSocket.Event.OnConnectionOpened<*>>
to
@receive
fun observeOnConnectionOpenedEvent(): Flowable<WebSocket.Event>

@dkambersky
Copy link

dkambersky commented Aug 24, 2018

@7va can you share the Scarlet portions of your build.gradle? Changing to WebSocket.Event leads to

java.lang.IllegalStateException: Cannot resolve stream adapter for type io.reactivex.Flowable<com.tinder.scarlet.WebSocket$Event>

for me.

@kikebodi
Copy link
Author

kikebodi commented Sep 4, 2018

In my case @Receive fun observeOnConnectionOpenedEvent(): Flowable<WebSocket.Event> compiles but never gets a response on subscribe().

@dkambersky this is how my Gradle looks like:
def scarletVersion = "0.1.4"
implementation "com.github.tinder.scarlet:scarlet:$scarletVersion"
implementation "com.github.tinder.scarlet:scarlet-websocket-okhttp:$scarletVersion"
implementation "com.github.tinder.scarlet:scarlet-websocket-mockwebserver:$scarletVersion"
implementation "com.github.tinder.scarlet:scarlet-stream-adapter-rxjava2:$scarletVersion"
implementation "com.github.tinder.scarlet:scarlet-message-adapter-gson:$scarletVersion"
implementation "com.github.tinder.scarlet:scarlet-lifecycle-android:$scarletVersion"

@okaymak
Copy link

okaymak commented Sep 6, 2018

I had the same issue, but finally managed to make it work like this:

interface MyService {
    @Receive
    fun observeOnConnectionOpenedEvent(): Flowable<WebSocket.Event>
}

and then:

    myService.observeOnConnectionOpenedEvent().subscribe {
            when (it) {
                is WebSocket.Event.OnConnectionOpened<*> -> Log.d("Socket", "Connection opened")
                is WebSocket.Event.OnConnectionClosing -> Log.d("Socket", "Connection closing")
                is WebSocket.Event.OnConnectionClosed -> Log.d("Socket", "Connection closed")
                is WebSocket.Event.OnConnectionFailed -> Log.e("Socket", "Connection failed", it.throwable)
                is WebSocket.Event.OnMessageReceived -> Log.d("Socket", "Message received")
                else -> Log.d("Socket", it.toString())
            }
        }

@zhxnlai
Copy link
Collaborator

zhxnlai commented Sep 27, 2018

@7va can you share the Scarlet portions of your build.gradle? Changing to WebSocket.Event leads to

java.lang.IllegalStateException: Cannot resolve stream adapter for type io.reactivex.Flowable<com.tinder.scarlet.WebSocket$Event>

for me.

@dkambersky I think you might have forgotten to add a scarlet-stream-adapter-rxjava2

zhxnlai added a commit that referenced this issue Oct 24, 2018
Fix #22: Update Usage example on README.md to match current implement…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants