Resources referenced from the manifest cannot vary by configuration(except for version qualifiers, e.g. -v21.) Found variation in zh-rCN
facebook登录功能实现步骤:
1,写一个string资源,名字无所谓,如facebook_application_id.
2,配置facebook activity和mete-data
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:label="@string/app_name" />
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
1,如果软件支持多种语言,就一定要编写多个string文件,在每个string文件中定义facebook_application_id,此时出现错误如下:
2,好像是说不能在不同文件中定义两个id,所以就删了一个呗。。。然后打包时就出现了下面的错:
3,所以就不配置application_id了,直接在manifest文件meta-data中写value,不引用string,但是这时就出现如下错误:
这也不行,那也不行,我本来要告诉老大实现不了呢,万念俱灰下看了下facebook代码库,发现applicationId赋值代码如下(FacebookSdk类):
if (applicationId == null) {
Object appId = ai.metaData.get(APPLICATION_ID_PROPERTY);
if (appId instanceof String) {
String appIdString = (String) appId;
if (appIdString.toLowerCase(Locale.ROOT).startsWith("fb")) {
applicationId = appIdString.substring(2);
} else {
applicationId = appIdString;
}
} else if (appId instanceof Integer) {
throw new FacebookException(
"App Ids cannot be directly placed in the manifest." +
"They must be prefixed by 'fb' or be placed in the string resource file.");
}
}
如果appId是字符串,大写变小写后以fb开头就把fb去了用后面的,于是想到可以在meta-data中直接用申请的id前加fb的字符串,试了试,果然成了。
哈哈,那一个开心,简直不是一顿饭两顿饭能比的,简直重新认识了世界,重新睁开了眼睛,哈哈哈哈。。。。。。。。。。。。。。。。。。。。