Using grpc dependencies in plugin gives errors

Getting the following error

io.grpc.ManagedChannelProvider: Provider io.grpc.netty.NettyChannelProvider not a subtype

I have the following dependencies in the plugin.


I see io.grpc.ManagedChannelProvider exists in studio-profiler-grpc-1.0-jarjar.jar(IC-172.3317.76) and grpc-netty which might be creating the above problem.

Any help will be appreciated.


Does your plugin depend on 'android' plugin?


No, It doesn't depend on android plugin.


It's strange then. Classes of your plugins are loaded by a separate class loader, which shouldn't see classes from Android plugin. You can debug the code and look which classloader is used to load ManagedChannelProvider's services.


Did you get a solution to this? I am having the same problem with studio-profiler-grpc-1.0-jarjar - it contains the class

io/grpc/okhttp/OkHttpChannelProvider which is loaded unintentionally by the grpc-java lib that is bundled with my plugin on this line:
That causes it to crash as it isn't the class it was expecting :
Caused by: java.lang.ClassCastException: class io.grpc.okhttp.OkHttpChannelProvider
    at java.lang.Class.asSubclass(
What I need to happen is for it not to find that class and so load the NettyChannelProvider:
Is there a way to achieve this? Obviously this is only an issue in Android Studio. 

I also encountered this problem after upgrading the AS to Bumblebee | 2021.1.1.

In Arctic Fox | 2020.3.1, the ClassLoader used to load ManagedChannelProvider is UrlClassLoader:

In Bumblebee | 2021.1.1, the ClassLoader is PluginClassLoader:


Please sign in to leave a comment.