我使用vimeo网络库(https://github.com/vimeo/vimeo-networking-java), exoplayer实现vimeo网络,并在这篇文章中解释https://stackoverflow.com/a/65737556/8814924
现在的问题是,当我检查API 30它得到错误
. lang。运行时异常:无法启动活动ComponentInfo{com. emergeningit . emergeningstudy/com. emergeningit . emergeningstudy .activities.course。{: java.lang.IllegalStateException:无法在Android10Platform上提取信任管理器,sslSocketFactory是类com.android.org.conscrypt.OpenSSLSocketFactoryImpl
由于:java.lang.IllegalStateException: Unable to extract the trust manager on Android10Platform, sslSocketFactory是class com.android.org.conscrypt.OpenSSLSocketFactoryImpl
表示
上的错误。VimeoClient.initialize(configuration);
这里讨论哪个问题:https://github.com/square/okhttp/issues/5878,问题讨论:
I assume you are calling the deprecated form of sslSocketFactory, which is broken on newer Android versions. https://github.com/square/okhttp/blob/master/okhttp/src/main/java/okhttp3/OkHttpClient.kt#L719
/**
* Sets the socket factory used to secure HTTPS connections. If unset, the system default will
* be used.
*
* @deprecated [SSLSocketFactory] does not expose its [X509TrustManager], which is a field that
* OkHttp needs to build a clean certificate chain. This method instead must use reflection
* to extract the trust manager. Applications should prefer to call
* `sslSocketFactory(SSLSocketFactory, X509TrustManager)`, which avoids such reflection.
*/
@Deprecated(
message = "Use the sslSocketFactory overload that accepts a X509TrustManager.",
level = DeprecationLevel.ERROR
)
fun sslSocketFactory(sslSocketFactory: SSLSocketFactory) = apply {
if (sslSocketFactory != this.sslSocketFactoryOrNull) {
this.routeDatabase = null
}
this.sslSocketFactoryOrNull = sslSocketFactory
this.certificateChainCleaner = Platform.get().buildCertificateChainCleaner(sslSocketFactory)
}
是否有使用当前版本"1.1.3"的解决方案?或者我必须等到库更新?
我主要使用Vimeo- networking库(v1.1.3)解决了Android 10平台上Vimeo视频流的问题。因为主要问题是在OkHttpClient构建方法
builder.sslSocketFactory(sSLSocketFactory);
//RetrofitClientBuilder.java#186
,其中1参数版本被弃用,我需要传递X509TTrustManager作为第二个参数,如下所示:
builder.sslSocketFactory(sSLSocketFactory, new X509TrustManager() {
@Override
public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
}
@Override
public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
}
@Override
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}
});
所以它解决了我的问题,直到这个更新出现在这个库的稳定版本。下面描述了我是如何实现的:
vimeclient .initialize(accessToken);行,我搜索了错误,发现这是由于OkHttpClient方法弃用(带1个参数)引起的。
所以我进入vimeclient .java,在它的构造函数private Retrofit createRetrofit()private OkHttpClient createOkHttpClient()被称为。public class RetrofitClientBuilder对象被创建,它的问题方法是public OkHttpClient build()式中:
if (sSLSocketFactory != null) { builder.sslSocketFactory(sSLSocketFactory); }
此已弃用的方法被调用。所以我只需要创建两个新的java文件名为VimeoClientUpdated.java和 RetrofitClientBuilderUpdated.java 这只是一个重命名的副本 vimeclient .java和 RetrofitClientBuilder.java 现在我的RetrofitClientBuilderUpdated.java没有弃用的方法,而是正确的和 vimeoclientupdate .java正在调用RetrofitClientBuilderUpdated.java(由于最终类的原因,我无法扩展,甚至无法将类包装为该解决方案的网关,我不得不面对无法在包装器类中更改的私有方法)
,最后只是而不是调用
VimeoClient.initialize(accessToken)
我调用我新创建的VimeoClientUpdated(accessToken)
不会崩溃,而在Android 10上播放Vimeo视频。
建议我是否有更好的方法来满足我的目的(解决从android活动中调用过时的库方法)。干杯! !