我正在开发一个使用 Facebook-SDKv3 的 Android 应用程序,所以我在 strings.xml 中创建了一个条目:
<resources>
<string name="facebook_app_id">"12345678910"</string>
</resources>
并将以下内容添加到 list 中:
<application>
...
<meta-data android:name="com.facebook.sdk.ApplicationId" android:resource="@string/facebook_app_id" />
</application>
我总是得到这个异常:
02-06 16:35:01.231: W/Bundle(8316): Key com.facebook.sdk.ApplicationId expected String but value was a java.lang.Integer. The default value was returned.
02-06 16:35:01.231: W/Bundle(8316): Attempt to cast generated internal exception:
02-06 16:35:01.231: W/Bundle(8316): java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
02-06 16:35:01.231: W/Bundle(8316): at android.os.Bundle.getString(Bundle.java:1061)
02-06 16:35:01.231: W/Bundle(8316): at com.facebook.internal.Utility.getMetadataApplicationId(Utility.java:159)
我已经尝试将数字放在 ""中,但这并没有解决问题,希望有人能帮助我。
最佳答案
将其从 android:resource
更改为 android:value
关于android - Android string.xml 中的类转换异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14733270/