Repository: square/retrofit
Issue: RxJavaCallAfapterFactory does not recognize rx.Single after proguarding

After proguarding application which uses retrofit service like

```
interface Service {
  @GET("/something")
  Single<String> getSomething();
}
```

retrofit fails with

```
java.lang.IllegalArgumentException: Could not locate call adapter for e.r<java.lang.String>.
                                                   Tried:
                                                    * retrofit2.adapter.rxjava.RxJavaCallAdapterFactory
                                                    * retrofit2.ExecutorCallAdapterFactory
                                                     at retrofit2.Retrofit.nextCallAdapter(Unknown Source)
                                                     at retrofit2.Retrofit.callAdapter(Unknown Source)
```


Issue comments:
`Single` is `@Beta` and as such [can be broken or removed at any time](https://github.com/ReactiveX/RxJava#beta). Retrofit will not put its presence in the critical path for all RxJava support until it graduates to stable.

You can tell ProGuard to not obfuscate this class for now.

Having this issue. `Single` is no longer `@Beta` since RxJava `1.2`.

And it's already been adjusted on `master` accordingly.

I'm sorry, was using `2.0.0-beta4`. I can't use latest version. How do I tell ProGuard not to obfuscate the class then?

```
-keep class retrofit2.adapter.rxjava.RxJavaCallAdapterFactory { *; }
```

does not seem to do the trick. Code still goes through [this execution path](https://github.com/square/retrofit/blob/2613d174be2e6f31f4f742e040412aee308849cf/retrofit-adapters/rxjava/src/main/java/retrofit2/adapter/rxjava/RxJavaCallAdapterFactory.java#L51) with the above configuration.

-keepnames class rx.Single

On Tue, Oct 11, 2016 at 2:11 PM david-perez notifications@github.com
wrote:

> I'm sorry, was using 2.0.0-beta4. I can't use latest version. How do I
> tell ProGuard not to obfuscate the class then?
> 
> -keep class retrofit2.adapter.rxjava.RxJavaCallAdapterFactory { *; }
> 
> does not seem to do the trick. Code still goes through this execution path
> https://github.com/square/retrofit/blob/2613d174be2e6f31f4f742e040412aee308849cf/retrofit-adapters/rxjava/src/main/java/retrofit2/adapter/rxjava/RxJavaCallAdapterFactory.java#L51
> with the above configuration.
> 
> —
> You are receiving this because you modified the open/close state.
> Reply to this email directly, view it on GitHub
> https://github.com/square/retrofit/issues/1584#issuecomment-252998320,
> or mute the thread
> https://github.com/notifications/unsubscribe-auth/AAEEEVpKywmbJrzhtlUrdiOXOiltadMYks5qy9FpgaJpZM4HXGRZ
> .


Pull request review comments:

Patch that resolved the issue:
diff --git a/retrofit-adapters/rxjava/src/main/java/retrofit2/adapter/rxjava/RxJavaCallAdapterFactory.java b/retrofit-adapters/rxjava/src/main/java/retrofit2/adapter/rxjava/RxJavaCallAdapterFactory.java
index f4b60209a7..f40a2877f0 100644
--- a/retrofit-adapters/rxjava/src/main/java/retrofit2/adapter/rxjava/RxJavaCallAdapterFactory.java
+++ b/retrofit-adapters/rxjava/src/main/java/retrofit2/adapter/rxjava/RxJavaCallAdapterFactory.java
@@ -46,7 +46,7 @@ private RxJavaCallAdapterFactory() {
   @Override
   public CallAdapter<?> get(Type returnType, Annotation[] annotations, Retrofit retrofit) {
     Class<?> rawType = getRawType(returnType);
-    boolean isSingle = "rx.Single".equals(rawType.getCanonicalName());
+    boolean isSingle = rawType == rx.Single.class;
     if (rawType != Observable.class && !isSingle) {
       return null;
     }


Test patch: