[Cordova] 編譯 InAppBrowser 出現 Expected resource of type id 的錯誤
有一陣子沒有用 Cordova 編譯 app 了,今天來編譯時,
意外出現了 Error: Expected resource of type id [ResourceType] 的錯誤訊息:
:compileReleaseSources :lintVitalRelease/Users/testuser/MultiLibraryLogin/platforms/android/src/org/apache/cordova/inappbrowser/InAppBrowser.java:555: Error: Expected resource of type id [ResourceType] actionButtonContainer.setId(1); ~ /Users/testuser/MultiLibraryLogin/platforms/android/src/org/apache/cordova/inappbrowser/InAppBrowser.java:563: Error: Expected resource of type id [ResourceType] back.setId(2); ~ /Users/testuser/MultiLibraryLogin/platforms/android/src/org/apache/cordova/inappbrowser/InAppBrowser.java:587: Error: Expected resource of type id [ResourceType] forward.setId(3); ~ /Users/testuser/MultiLibraryLogin/platforms/android/src/org/apache/cordova/inappbrowser/InAppBrowser.java:610: Error: Expected resource of type id [ResourceType] edittext.setId(4); ~ /Users/testuser/MultiLibraryLogin/platforms/android/src/org/apache/cordova/inappbrowser/InAppBrowser.java:633: Error: Expected resource of type id [ResourceType] close.setId(5); ~ /Users/testuser/MultiLibraryLogin/platforms/android/src/org/apache/cordova/inappbrowser/InAppBrowser.java:679: Error: Expected resource of type id [ResourceType] inAppWebView.setId(6); ~ Explanation for issues of type "ResourceType": Ensures that resource id's passed to APIs are of the right type; for example, calling Resources.getColor(R.string.name) is wrong. 6 errors, 0 warnings
查了一下,有人說是 Cordova plugin cordova-plugin-inappbrowser 的程式有 bug,
也提供了一些修改的方法:
stackoverflow: Cordova inAppBrowser “ResourceType” type issue for release build
不過那已經是去年的文章,想想 inAppBrowser 應該有出新版的了,
先用 cordova plugin list 查一下…
目前我的 cordova-plugin-inappbrowser 的版本是 1.0.1:
testuser@localhost ~/MultiLibraryLogin $ cordova plugin list cordova-plugin-dialogs 1.1.1 "Notification" cordova-plugin-inappbrowser 1.0.1 "InAppBrowser" cordova-plugin-whitelist 1.0.0 "Whitelist" de.appplant.cordova.plugin.email-composer 0.8.3dev "EmailComposer"
再用 cordova plugin search cordova-plugin-inappbrowser 查一下,最新版本是 1.4.0:
Cordova 似乎沒有直接更新 plugin 的指令,因此只能先移掉再安裝了:
cordova plugin remove cordova-plugin-inappbrowser cordova plugin add cordova-plugin-inappbrowser
更新好之後,重新執行 cordova build 就沒有問題囉~
參考資料:stackoverflow: Removing cordova plugins from the project
(本頁面已被瀏覽過 240 次)