question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

googleCredential fails on Android

See original GitHub issue

Thanks for stopping by to let us know something could be better!

GoogleCredential tries to use the Android/Apache version of Base64, not the one in the dependency. As this version is old, it doesn’t have the method decodeBase64.

This fails on the emulators and on a real Android device.

The code in client.util.base64 explicitly refers to the apache commons version of Base64, but this is not found at run-time.

Environment details

  • OS: Android 6 & 7
  • Java version: 1.8.0
  • google-api-java-client version: 27

Steps to reproduce

private static String getAccessToken(InputStream gc) throws IOException { GoogleCredential googleCredential = GoogleCredential .fromStream(gc) .createScoped(Arrays.asList(SCOPES));

Stacktrace

Caused by: java.lang.NoSuchMethodError: No static method decodeBase64(Ljava/lang/String;)[B in class Lorg/apache/commons/codec/binary/Base64; or its super classes (declaration of ‘org.apache.commons.codec.binary.Base64’ appears in /system/framework/org.apache.http.legacy.boot.jar) at com.google.api.client.util.Base64.decodeBase64(Base64.java:101) at com.google.api.client.util.PemReader.readNextSection(PemReader.java:106) at com.google.api.client.util.PemReader.readFirstSectionAndClose(PemReader.java:135) at com.google.api.client.googleapis.auth.oauth2.GoogleCredential.privateKeyFromPkcs8(GoogleCredential.java:904) at com.google.api.client.googleapis.auth.oauth2.GoogleCredential.fromStreamServiceAccount(GoogleCredential.java:877) at com.google.api.client.googleapis.auth.oauth2.GoogleCredential.fromStream(GoogleCredential.java:260) at com.google.api.client.googleapis.auth.oauth2.GoogleCredential.fromStream(GoogleCredential.java:226) at me.steve.TumblerListen.gCredTask.getAccessToken(gCredTask.java:33)



#### External references such as API reference guides used
Libraries in Gradle dependency list include
   implementation  'commons-codec:commons-codec:1.11'
    implementation 'com.google.http-client:google-http-client:1.27.0'
    implementation 'com.google.api-client:google-api-client:1.27.0'
- ?

#### Any additional information below



Thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

1reaction
chingor13commented, Jan 2, 2019

Downgrading to 1.25.0 or earlier should work until 1.28.0 is released (soon).

0reactions
chingor13commented, Jan 2, 2019

The google-http-client was not correctly shading/jarjar’ing the apache common-codec version and it conflicts with the built-in android one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

GoogleCredential won't build without GoogleCredential.Builder
I met this problem recently and figured out the solution for my case. Here is the running conditions: the program is running on...
Read more >
Class GoogleCredential (2.1.1) | Java client library
This is the built-in service account if running on Google Compute Engine or the credentials file from the path in the environment variable ......
Read more >
Google Sign-In for server-side apps | Authentication
There was an error. ... GoogleCredential credential = new GoogleCredential().setAccessToken(accessToken); Drive drive = new Drive.
Read more >
Authorize send requests | Firebase Cloud Messaging - Google
Android, Apple platform, and browser keys are rejected by FCM. ... If at any point the connection fails, you should immediately reconnect.
Read more >
GoogleCredential.getServiceAccountId - Java - Tabnine
@Override public String getServiceAccountId(GoogleCredential credential) { Assert. ... FATAL, "Unexpected error retrieving crypto key: " + e.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found