StorageServiceAccountSample application reports "KeyStore JKS implementation not found"
Asked Answered
K

2

9

The very first line of StorageServiceAccountSample

HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();

causes the "KeyStore JKS implementation not found":

W/System.err(20142): java.security.KeyStoreException: java.security.NoSuchAlgorithmException: KeyStore JKS implementation not found
W/System.err(20142):    at java.security.KeyStore.getInstance(KeyStore.java:119)
W/System.err(20142):    at com.google.api.client.util.SecurityUtils.getJavaKeyStore(SecurityUtils.java:48)
W/System.err(20142):    at com.google.api.client.googleapis.GoogleUtils.getCertificateTrustStore(GoogleUtils.java:74)
W/System.err(20142):    at com.google.api.client.googleapis.javanet.GoogleNetHttpTransport.newTrustedTransport(GoogleNetHttpTransport.java:55)

As I read Android doesn't support JKS, how should I modify this method to work around it?

Komi answered 18/9, 2013 at 2:7 Comment(0)
K
10

Replaced

HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();

with

HTTP_TRANSPORT = AndroidHttp.newCompatibleTransport();

and the problem went away.

Komi answered 18/9, 2013 at 21:39 Comment(2)
For those who follow this route, AndroidHttp class is in the com.google.api.client.extensions.android.http package. Not com.google.api.client.extensions.android2.AndroidHttp, which is deprecatedAdmissible
Yes the first GoogleNetHttpTransport works fine for Java (or non-android Test) and the second AndroidHttp is required when running on Android. This is packaged as an extension of the Google API Client for Android. In my case : implementation 'com.google.api-client:google-api-client-android:1.25.0'Subotica
B
2

I've found an answer on google issue tracker.

Replace

HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();

with

HTTP_TRANSPORT = new com.google.api.client.http.javanet.NetHttpTransport()

But don't know, how it's working.

Bittern answered 2/9, 2016 at 5:43 Comment(1)
@Martijin Pieters Tell me How could it be identical answer? see the Jerry's answer. It's totally different from my answer.(compare code snippet) Watch carefully before deleting the answer. That's why I'm posting the same answer again.Bittern

© 2022 - 2024 — McMap. All rights reserved.