8000 googleCredential fails on Android · Issue #1220 · googleapis/google-api-java-client · GitHub
[go: up one dir, main page]

Skip to content
googleCredential fails on Android #1220
@steve78b

Description

@steve78b

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!

Metadata

Metadata

Assignees

Labels

priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0