I am developing an Android-App that uses the Facebook-SDKv3, so I created an entry in the strings.xml:
<resources>
<string name="facebook_app_id">"12345678910"</string>
</resources>
and added the following to the Manifest:
<application>
...
<meta-data android:name="com.facebook.sdk.ApplicationId" android:resource="@string/facebook_app_id" />
</application>
I always get this Exception:
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)
I already tried to put the Numbers in "" but this did not solve the Problem, hope somebody can help me.
The java.lang.ClassCastException is one of the unchecked exception in Java. It can occur in our program when we tried to convert an object of one class type into an object of another class type. When will be ClassCastException is thrown When we try to cast an object of Parent class to its Child class type, this exception will be thrown.
For example, an Integer object cannot be cast to a String object. This exception extends the RuntimeException class and thus belongs to those exceptions that can be thrown during the operation of the Java Virtual Machine (JVM).
When we try to cast an object of Parent class to its Child class type, this exception will be thrown. When we try to cast an object of one class into another class type that has not extended the other class or they don't have any relationship between them.
Exception in thread “main” java.lang.ClassCastException: class java.math.BigDecimal cannot be cast to class java.lang.String (java.math.BigDecimal and java.lang.String are in module java.base of loader ‘bootstrap’) We can fix the exception printing by means of converting the code in the below format:
Change it from android:resource
to android:value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With