這個問題排查了幾個小時。在這裏提供一下具體的排查思路,但願能給各位老鐵一點提示。react
昨天原本打包還好好的。今天在 android 打包的時候,今天忽然間有一個奇怪的報錯,致使打包失敗了:android
/Users/PAMPANG/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/aeb63fa7e61ad852e8a67f3e8b29c11b/res/values/values.xml:251:5-69: AAPT: error: resource android:attr/fontVariationSettings not found.
/Users/PAMPANG/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/aeb63fa7e61ad852e8a67f3e8b29c11b/res/values/values.xml:251:5-69: AAPT: error: resource android:attr/ttcIndex not found.
error: failed linking references.
FAILURE: Build failed with an exception.
複製代碼
嗯??什麼奇怪的錯誤??git
定睛一看,錯誤中有關鍵詞:github
appcompat-v7-27.1.1.aar
AAPT: error: resource android:attr/fontVariationSettings not found
複製代碼
OK,根據這兩個關鍵詞上網衝浪去。web
咱們用的是 react-native
,所以先看看 react-native
的 issue 裏有沒有相似的問題。react-native
搜到了兩個相關的 issue:bash
https://github.com/facebook/react-native/issues/25338
https://github.com/crosswalk-project/cordova-plugin-crosswalk-webview/issues/207
複製代碼
經過這兩個連接,又發現了一個 stackOverFlow 的網站:app
https://stackoverflow.com/questions/56654226/ionic-cordova-app-stopped-compiling-after-googles-june-17th-firebase-sdk-update
複製代碼
在這裏,我獲得了有效信息:google 在 20190617 發佈了新版本,須要作 XXX 才能適配。我虎軀一震,難道要我更新?!ionic
但再細細一想,不該該啊,那全部的 android 項目不都得掛了?應該是個人包裏有了什麼錯誤的依賴致使的。ide
帶着這個問題,我再次搜索信息。
我又從新開始查信息了。這個 issue 中一位小哥的回答給了我很大的提示。他的主要思路是整個 app 的依賴列表輸出出來,看看哪一個小壞蛋引入了不應有的依賴。
我在命令行運行 ./gradlew app:dependencies
把整個 app 的依賴列表輸出出來,對應着 google 的更新列表,看看究竟是哪一個小壞蛋引用了最新的依賴。
根據包名搜索了一番,發現是 react-native-device-info
中引用了 gms
,而 gms
的版本號是 +
,即直接去最新版,因此就拿了最新的版本依賴了。而這個最新的版本,是須要作適配才能啓用的,所以就出問題了。
能夠看到,在 react-native-device-info@0.24.3 的這一行代碼 中,用 +
號引入了 gms
。
那麼,想要解決就很簡單了:
根據 這個 issue 連接 中的提示,加一個常量 googlePlayServicesVersion
,給固定版本便可 或者,更新 react-native-device-info
到最新版,它對這個依賴的版本號加了一個默認版本,而不是 + 了。
至此,problem solved。
google 在 20190617 發佈了新的更新: stackoverflow.com/questions/5…
google 更新查詢列表: developers.google.com/android/gui…
google 依賴列表: ./gradlew app:dependencies