0

I'm using Facebook SDK project on my own project by adding it as a library inside my workspace, like:

Project properties -> Android -> Add.. -> Facebook SDK

Like this i have access to classes and resources inside this project. For example in one of my layout files i have:

android:drawable="@drawable/com_facebook_loginbutton_blue_normal" 

But if i want to change the way i use this Facebook SDK project, and simple export it as jar file, and add it to libs folder in my app, i have the error:

error: Error: No resource found that matches the given name (at 'drawable' with value '@drawable/com_facebook_loginbutton_blue_normal').

How to access the resources inside my jar file?

2 Answers2

1

The short answer is, you can't. The Facebook SDK is an android library, and is being shipped as such, and should be used as such. Trying to import it as just a jar file will not work. Do you have a specific use case that requires you to only use jar libraries?

Ming Li
  • 15,639
  • 3
  • 35
  • 35
  • Android uses library projects exactly for the resource issues. The library project takes care of merging all resources into the final APK and making sure they are all accessible by ID. The IDs are integers (which you can see when you look at the generated R file). These must be unique within the APK so it is not possible to bundle them in a jar unless you load them in a completely different way. (getResourceAsStream() but that sucks because it doesn't handle screen size and resolution issues.) – Nick Palmer May 08 '13 at 16:35
  • I just wanted to make my project independent. If i need to synchronize my project with someone else, the other users will need to import the project Facebook SDK for the main project work. – user2340677 May 09 '13 at 10:27
0

From what i can understand..

That,s because that drawable resource is in different package than yours, try accessing it with full package name

EDIT

What I meant was add

android:drawable="@packageName:drawable/com_facebook_loginbutton_blue_normal"

Like this:-

android:drawable="@com.google.android:drawable/com_facebook_loginbutton_blue_normal"

I don't know what package name is defined in Android SDk so change package name accordingly.

Hope this helps.

CRUSADER
  • 6,189
  • 3
  • 31
  • 60
  • What would you suggest? sorry but im lost. Inside my jar the path would be: res -> drawable -> name_of_picture – user2340677 May 08 '13 at 11:54
  • in my case i would have: '@com.facebook.android:drawable/com_facebook_loginbutton_blue_pressed', but still not working: No resource found that matches the given name (at 'drawable' with value '@com.facebook.android:R $drawable/com_facebook_loginbutton_blue_pressed'). – user2340677 May 08 '13 at 12:19
  • HAve you imported that external jar file properly. [Check this link](http://stackoverflow.com/a/6859020/2345913). Let me know if your issue is resolved. – CRUSADER May 08 '13 at 12:31
  • Thanks for the hint, but still not working. The same error: "No resource found that matches the given name ..." – user2340677 May 08 '13 at 12:37
  • I checked insdie my jar and the path is correct. I also checked the R.java file and this picture is there. inside res/drawable the picture is there. It seems to be everything ok inside the jar file, but somehow we cannot find it. – user2340677 May 08 '13 at 12:38