关于百度语音在安卓9.0上无法正常合成的解决方法

问题现象
  • 开发的一款APP,集成了百度语音合成的功能,前段时间APP功能都OK。
  • 可是最近同样的手机同样的APP,这个语音合成功能就不行了,调试发现报如下错误。
W/System.err: javax.net.ssl.SSLException: hostname in certificate didn't match: <182.61.240.40> != <baidu.com> OR <baidu.com> OR <click.hm.baidu.com> OR <cm.pos.baidu.com> OR <log.hm.baidu.com> OR <update.pan.baidu.com> OR <wn.pos.baidu.com> OR <*.91.com> OR <*.aipage.cn> OR <*.aipage.com> OR <*.apollo.auto> OR <*.baidu.com> OR <*.baidubce.com> OR <*.baiducontent.com> OR <*.baidupcs.com> OR <*.baidustatic.com> OR <*.baifae.com> OR <*.baifubao.com> OR <*.bce.baidu.com> OR <*.bcehost.com> OR <*.bdimg.com> OR <*.bdstatic.com> OR <*.bdtjrcv.com> OR <*.bj.baidubce.com> OR <*.chuanke.com> OR <*.dlnel.com> OR <*.dlnel.org> OR <*.dueros.baidu.com> OR <*.eyun.baidu.com> OR <*.fanyi.baidu.com> OR <*.gz.baidubce.com> OR <*.hao123.baidu.com> OR <*.hao123.com> OR <*.hao222.com> OR <*.im.baidu.com> OR <*.map.baidu.com> OR <*.mbd.baidu.com> OR <*.mipcdn.com> OR <*.news.baidu.com> OR <*.nuomi.com> OR <*.safe.baidu.com> OR <*.smartapps.cn> OR <*.ssl2.duapps.com> OR <*.su.baidu.com> OR <*.trustgo.com> OR <*.xueshu.baidu.com> OR <apollo.auto> OR <baifae.com> OR <baifubao.com> OR <dwz.cn> OR <mct.y.nuomi.com> OR <www.baidu.cn> OR <www.baidu.com.cn>
W/System.err:     at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:191)
W/System.err:     at org.apache.http.conn.ssl.BrowserCompatHostnameVerifier.verify(BrowserCompatHostnameVerifier.java:59)
W/System.err:     at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:120)
W/System.err:     at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:101)
        at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:340)
W/System.err:     at org.apache.http.conn.scheme.SchemeSocketFactoryAdaptor.connectSocket(SchemeSocketFactoryAdaptor.java:66)
W/System.err:     at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180)
W/System.err:     at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:144)
        at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:134)
W/System.err:     at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:605)
W/System.err:     at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:440)
W/System.err:     at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:835)
W/System.err:     at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
W/System.err:     at com.baidu.tts.loopj.AsyncHttpRequest.makeRequest(AsyncHttpRequest.java:146)
W/System.err:     at com.baidu.tts.loopj.AsyncHttpRequest.makeRequestWithRetries(AsyncHttpRequest.java:177)
W/System.err:     at com.baidu.tts.loopj.AsyncHttpRequest.run(AsyncHttpRequest.java:107)
        at com.baidu.tts.loopj.SyncHttpClient.sendRequest(SyncHttpClient.java:93)
W/System.err:     at com.baidu.tts.loopj.AsyncHttpClient.post(AsyncHttpClient.java:1043)
W/System.err:     at com.baidu.tts.b.a.b.f$a.a(OnlineSynthesizer.java:345)
        at com.baidu.tts.b.a.b.f$a.call(OnlineSynthesizer.java:261)
W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
W/System.err:     at java.lang.Thread.run(Thread.java:764)
W/System.err: javax.net.ssl.SSLException: hostname in certificate didn't match: <182.61.240.40> != <baidu.com> OR <baidu.com> OR <click.hm.baidu.com> OR <cm.pos.baidu.com> OR <log.hm.baidu.com> OR <update.pan.baidu.com> OR <wn.pos.baidu.com> OR <*.91.com> OR <*.aipage.cn> OR <*.aipage.com> OR <*.apollo.auto> OR <*.baidu.com> OR <*.baidubce.com> OR <*.baiducontent.com> OR <*.baidupcs.com> OR <*.baidustatic.com> OR <*.baifae.com> OR <*.baifubao.com> OR <*.bce.baidu.com> OR <*.bcehost.com> OR <*.bdimg.com> OR <*.bdstatic.com> OR <*.bdtjrcv.com> OR <*.bj.baidubce.com> OR <*.chuanke.com> OR <*.dlnel.com> OR <*.dlnel.org> OR <*.dueros.baidu.com> OR <*.eyun.baidu.com> OR <*.fanyi.baidu.com> OR <*.gz.baidubce.com> OR <*.hao123.baidu.com> OR <*.hao123.com> OR <*.hao222.com> OR <*.im.baidu.com> OR <*.map.baidu.com> OR <*.mbd.baidu.com> OR <*.mipcdn.com> OR <*.news.baidu.com> OR <*.nuomi.com> OR <*.safe.baidu.com> OR <*.smartapps.cn> OR <*.ssl2.duapps.com> OR <*.su.baidu.com> OR <*.trustgo.com> OR <*.xueshu.baidu.com> OR <apollo.auto> OR <baifae.com> OR <baifubao.com> OR <dwz.cn> OR <mct.y.nuomi.com> OR <www.baidu.cn> OR <www.baidu.com.cn>
W/System.err:     at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:191)
W/System.err:     at org.apache.http.conn.ssl.BrowserCompatHostnameVerifier.verify(BrowserCompatHostnameVerifier.java:59)
W/System.err:     at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:120)
        at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:101)
W/System.err:     at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:340)
W/System.err:     at org.apache.http.conn.scheme.SchemeSocketFactoryAdaptor.connectSocket(SchemeSocketFactoryAdaptor.java:66)
W/System.err:     at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180)
        at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:144)
W/System.err:     at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:134)
W/System.err:     at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:605)
W/System.err:     at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:440)
        at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:835)
W/System.err:     at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
W/System.err:     at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
W/System.err:     at com.baidu.tts.loopj.AsyncHttpRequest.makeRequest(AsyncHttpRequest.java:146)
        at com.baidu.tts.loopj.AsyncHttpRequest.makeRequestWithRetries(AsyncHttpRequest.java:177)
W/System.err:     at com.baidu.tts.loopj.AsyncHttpRequest.run(AsyncHttpRequest.java:107)
W/System.err:     at com.baidu.tts.loopj.SyncHttpClient.sendRequest(SyncHttpClient.java:93)
        at com.baidu.tts.loopj.AsyncHttpClient.post(AsyncHttpClient.java:1043)
W/System.err:     at com.baidu.tts.b.a.b.f$a.a(OnlineSynthesizer.java:345)
W/System.err:     at com.baidu.tts.b.a.b.f$a.call(OnlineSynthesizer.java:261)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
W/System.err:     at java.lang.Thread.run(Thread.java:764)

解决方法
  • 后来查看了我的手机系统,因为最近升过级,升到了Android 9,才意识到可能是这个原因
  • 又上网去查询各种官网、论坛,找了试了我整整一晚,终于在一些不起眼的地方找到了答案,就是把targetSdkVersion由28改成27就行了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值