简体   繁体   English

使用jar中的资源(Facebook SDK为jar)

[英]use resources from jar (Facebook SDK as jar)

I'm using Facebook SDK project on my own project by adding it as a library inside my workspace, like: 我在自己的项目上使用Facebook SDK项目,方法是将其添加为工作区中的库,例如:

Project properties -> Android -> Add.. -> Facebook SDK 项目属性-> Android->添加..-> 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: 但是,如果我想更改使用此Facebook SDK项目的方式,并简单地将其导出为jar文件,并将其添加到我的应用程序的libs文件夹中,则会出现错误:

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? 如何访问我的jar文件中的资源?

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. Facebook SDK是一个android库,因此按其本身的方式发送,应按原样使用。 Trying to import it as just a jar file will not work. 尝试仅将其导入为jar文件将无法正常工作。 Do you have a specific use case that requires you to only use jar libraries? 您是否有一个特定的用例,只需要使用jar库?

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. 我不知道Android SDk中定义了什么包名称, 因此请相应地更改包名称

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM