Runtime error Android 10平台(api29)的Vimeo网络库崩溃
我使用vimeo networking library()、exoplayer实现了vimeo网络,并在本文中进行了解释 现在的问题是,当我用API 30检查时,它出现了错误 java.lang.RuntimeException:无法启动活动组件信息{com.emergingit.emergingstudy/com.emergingit.emergingstudy.activities.course.ExoPlayerActivity}:java.lang.IllegalStateException:无法在Android10平台上提取信任管理器,sslSocketFactory是类com.android.org.conscret.OpenSSLSocketFactoryImpl 原因:java.lang.IllegalStateException:无法在Android10Platform上提取信任管理器,sslSocketFactory的类为com.android.org.conscrypt.OpenSSLSocketFactoryImpl 这表明了上的错误Runtime error Android 10平台(api29)的Vimeo网络库崩溃,runtime-error,android-10.0,sslsocketfactory,vimeo-android,trustmanager,Runtime Error,Android 10.0,Sslsocketfactory,Vimeo Android,Trustmanager,我使用vimeo networking library()、exoplayer实现了vimeo网络,并在本文中进行了解释 现在的问题是,当我用API 30检查时,它出现了错误 java.lang.RuntimeException:无法启动活动组件信息{com.emergingit.emergingstudy/com.emergingit.emergingstudy.activities.course.ExoPlayerActivity}:java.lang.IllegalStateExcepti
VimeoClient.initialize(configuration);
这里讨论的是哪个问题:,问题讨论:
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网络库(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];
}
});
所以它解决了我的问题,直到这个更新进入这个库的稳定版本。我是如何实现这一点的,如下所述:
if(sSLSocketFactory!=null){builder.sSLSocketFactory(sSLSocketFactory);}
调用了此不推荐使用的方法
VimeoClient.initialize(accessToken)
而是调用我新创建的VimeoClientUpdated(accessToken)
,它在Android 10上播放Vimeo视频时不会崩溃
干杯 这将禁用应用程序中的安全性。Vimeo库需要停止调用无法在所有平台上支持的长期不推荐的方法。@YuriSchimke是否禁用了应用程序的安全性?你能详细说明一下吗。。。由于没有其他/更新版本的库并调用去擦洗方法,因此恢复安全性的方法是什么,因为我必须这样做才能使其正常工作?要构建sslSocketFactory,您通常已经拥有真正的truatmanager。传入noop版本只会使连接不安全。