google / java-photoslibrary

Java client library for the Google Photos Library API
http://developers.google.com/photos
Apache License 2.0
107 stars 64 forks source link

No functional channel service provider found. Try adding a dependency on the grpc-okhttp or grpc-netty artifact #9

Closed panovvitalik closed 5 years ago

panovvitalik commented 5 years ago

Added: implementation 'com.google.photos.library:google-photos-library-client:1.1.0'

Trying to exexecute this code: PhotosLibrarySettings settings = PhotosLibrarySettings.newBuilder() .setCredentialsProvider( FixedCredentialsProvider.create(UserCredentials.newBuilder() .setClientId(GOOGLE_CLIENT_ID) .setClientSecret(GOOGLE_CLIENT_SECRET) .setAccessToken(new AccessToken("my access token", null)) .build())) .build();

        PhotosLibraryClient photosLibraryClient =
                PhotosLibraryClient.initialize(settings); 

Getting this error: io.grpc.ManagedChannelProvider$ProviderNotFoundException: No functional channel service provider found. Try adding a dependency on the grpc-okhttp or grpc-netty artifact

Please help. What should I do to fix this issue

panovvitalik commented 5 years ago

I was cut off using of this "shi..." library from my project. And reimplemented all work with direct REST calls. "Thank you"

So question is not actual.

wmcalyj commented 5 years ago

I have the same issue and cannot find any workaround. Any idea how this can be solved?

panovvitalik commented 5 years ago

I have the same issue and cannot find any workaround. Any idea how this can be solved?

I fixed it like this way, pls see code below: BUT! many fllowing issues I can not resolve, It looks like this library is not supporting :( . And I advice to reimplement Your code to direct REST calls - I already did it.

implementation ('io.grpc:grpc-protobuf:1.10.1'){ exclude group: 'org.apache.httpcomponents', module:'httpclient' } implementation ('io.grpc:grpc-stub:1.10.1'){ exclude group: 'org.apache.httpcomponents', module:'httpclient' } implementation ('com.google.api:gax:1.29.0'){ exclude group: 'org.apache.httpcomponents', module:'httpclient' } implementation ('io.grpc:grpc-okhttp:1.10.1'){ exclude group: 'org.apache.httpcomponents', module:'httpclient' } implementation ('com.google.photos.library:google-photos-library-client:1.1.0'){ exclude group: 'org.apache.httpcomponents', module:'httpclient' } implementation 'org.apache.httpcomponents:httpclient-android:4.3.5.1'

wmcalyj commented 5 years ago

Thank you! I tried the following dependencies and it works for me. Although I doubt you need it anymore at this moment :)

com.google.photos.library google-photos-library-client 1.1.0 com.google.guava * com.google.api api-common 1.6.0 com.google.api gax-grpc 1.29.0 com.google.api gax 1.29.0 com.google.api.grpc proto-google-common-protos 1.12.0 com.google.protobuf protobuf-java 3.5.1 io.grpc grpc-protobuf 1.10.1 io.grpc grpc-stub 1.10.1 org.apache.httpcomponents httpclient 4.5.5 com.google.api-client google-api-client 1.24.1 com.google.oauth-client google-oauth-client-jetty 1.24.1 commons-httpclient commons-httpclient 3.1 io.grpc grpc-netty 1.10.1 com.google.guava * io.netty netty-tcnative-boringssl-static 2.0.23.Final
panovvitalik commented 5 years ago

Exactly :)

Next Your issues when using this library possibly can be:

https://github.com/google/java-photoslibrary/issues/15 https://github.com/google/java-photoslibrary/issues/11

And these issues I cannot resolve :(

hmallepally commented 4 years ago

I found this to be a dependency issue. I have seen this problem and upon investigation, the code is internally trying to load android Application class with class.forName and if successful, it treats it as android and otherwise it is non android.

problem I saw was because some dependency I had android jar into my classpath (google guava android or so) so excluded that dependency and it worked pretty fine.

I think the error message should be improved and give more meaningful message than asking to add grpc-netty, because the error can happen even with grpc-netty in classpath.

jfschmakeit commented 4 years ago

@hmallepally Could you share some more details about the dependency issue? It would be great if you can share the exact dependency that's causing the problem. What did you have to exclude? Was this just grpc-netty?

(Note that this library is not tested/supported on Android yet. I believe some of our dependencies have Android-specific versions that may help address some of these issues too, otherwise this is something we may have to take further upstream.)