好久没写了,今天遇到了这个问题,虽然可能国内的朋友可能很少遇上,但还是随心的记录一下,毕竟搞了两小时,就两行代码而已。
直接到主题:应用要使用facebook 登录,根据官方文档一步一步来,一切都很顺利,当到最后要打包的时候,却遇到了无法打包的问题。
Errors before ignored: .../src/main/AndroidManifest.xml:109: Error: Resources referenced from the manifest cannot vary by configuration (except for version qualifiers, e.g. -v21.) Found variation in zh-rTW [ManifestResource] android:value="@string/facebook_app_id"/> ~~~~~~~~~~~~~~~~~~~~~~~ .../src/main/res/values-zh-rTW/strings.xml:151: This value will not be used Explanation for issues of type "ManifestResource": Elements in the manifest can reference resources, but those resources cannot vary across configurations (except as a special case, by version, and except for a few specific package attributes such as the application title and icon.)
异常就是这样,一开始还把
<string name="facebook_app_id" translatable="false">******************</string>
直接复制到:zh\strings.xml 里面,又报出了另一个错误。所以最终的解决办法是:
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id" tools:ignore="ManifestResource"/><string name="facebook_app_id" translatable="false">*****************</string>是的,在meta-data中加入tools:ignore="ManifestResource"以及在string 的字段里加上 translatable="false" 就是不翻译的意思,就是这么简单。参照了:https://code.google.com/p/android/issues/detail?id=194705 和 http://stackoverflow.com/questions/35388688/android-facebook-app-id-showing-error-in-values-ta-strings-xml-and-cant-able