Skip to main content
March 27, 2015
Answered

Android resources with Facebook SDK 4.0

  • March 27, 2015
  • 1 reply
  • 634 views

Hello,

I am trying out the latest Facebook SDK for Android to create an ANE but I have quickly run into issues with resources.

FacebookActivity class uses R.layout.com_facebook_activity_layout and R.id.com_facebook_fragment_container.

If I use the R.* mechanism then the application crashes with 'resource not found' exception,

if I use aneContext.getResourceId then it does not crash but outputs warnings


W/ResourceType﹕ getEntry failing because entryIndex 10 is beyond type entryCount 3

W/ResourceType﹕ Failure getting entry for 0x7f04000a (t=3 e=10) in package 0 (error -2147483647)


I use platform.xml to specify packaged resources. I have to say, I use the same ANE setup (ie. resources packaging) with Facebook SDK 3.23 and it works fine.

The new Facebook SDK works fine in native Android app but in ANE it seems to be failing in class FragmentManager so it basically cannot find the container view.


...

case Fragment.CREATED:

  if (newState > Fragment.CREATED) {

  if (DEBUG) Log.v(TAG, "moveto ACTIVITY_CREATED: " + f);

  if (!f.mFromLayout) {

     ViewGroup container = null;

     if (f.mContainerId != 0) {

         container = (ViewGroup)mContainer.findViewById(f.mContainerId);

         if (container == null && !f.mRestored) {

             throwException(new IllegalArgumentException(

                     "No view found for id 0x"

                     + Integer.toHexString(f.mContainerId) + " ("

                     + f.getResources().getResourceName(f.mContainerId)

                     + ") for fragment " + f));

         }

     }

...

Any ideas that I could try to fix this?

This topic has been closed for replies.
Correct answer

Oh well, so I found out it was actually failing to get the resource R.string so I modified the Facebook SDK source

and replaced R.string calls to ANE Context's getActivity().getString( getResourceId( resourceId ) )


I tried using the platform.xml and packagedResource for various com.facebook packages but still could not get it to work

with the R.* mechanism so this will have to do for now.

1 reply

Correct answer
March 27, 2015

Oh well, so I found out it was actually failing to get the resource R.string so I modified the Facebook SDK source

and replaced R.string calls to ANE Context's getActivity().getString( getResourceId( resourceId ) )


I tried using the platform.xml and packagedResource for various com.facebook packages but still could not get it to work

with the R.* mechanism so this will have to do for now.