[ Android ] Android 9.0 開發問題筆記

內文記錄一些Android 9.0上開發所碰到的問題






1. GoogleMap 的 Runtime 錯誤

在測試SideProject時發現一個問題

Android 9 的環境之下開啟GoogleMap畫面會出現下列錯誤

java.lang.NoClassDefFoundError:failed resolution of :Lorg/apache/http/ProtocolVersio

上網查了一下討論,似乎是GoogleMap SDK本身的Bug

而解決的辦法很簡單

僅需要在Minifest.xml中 <application> 區塊中加入下列的標籤

<uses-library android:name="org.apache.http.legacy" android:required="false" />

如此就可以正常使用了


參考資料:
https://stackoverflow.com/questions/50461881/java-lang-noclassdeffounderrorfailed-resolution-of-lorg-apache-http-protocolve




2. URL必須使用HTTPS協定 ( 未測試 )

在Android 9.0使用像是 WebView 元件時,其網址必須是HTTPS

否則系統會把網址擋掉

而除了更改協定外,也可以透過下列方式把阻擋的機制關閉

在<application>標籤內加入下列設定

<application
...
   android:usesCleartextTraffic="true"
...
>
</application>


參考資料:
https://stackoverflow.com/questions/52594637/webview-is-not-loading-page-in-android-9-0














沒有留言:

張貼留言

Layout疑難雜症筆記

 這裡記錄一些Layout時View元件比較特殊的狀況與處理方式,內容會陸續增加。