Android Library Project - Resources$NotFoundException

非 Y 不嫁゛ 提交于 2020-01-06 02:20:11

问题


I'm trying to create a library project to use it for a Unity3d Plugin. All is correct but when i'm trying to show a custom progressDialog for example i'm doing this, getting Resources$NotFoundException

    LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View layout = inflater.inflate(com.myapp.test.R.layout.loading, null);
            layout.setMinimumWidth((int)(displayRectangle.width() * 0.9f));
            layout.setMinimumHeight((int)(displayRectangle.height() * 0.9f));

            progress.setView(layout);

I'm doing something wrong? My Library project ( jar file ) seems that not contains any layouts or resources... I have put in preferences of eclipse Is Library true.


回答1:


You cannot package resources into a jar file. Suggest you make a library project and refer the same in your android project.

For more information check the link below

http://developer.android.com/tools/projects/index.html

Right click on the project, goto properties, choose android, choose Is Library (tick).

To refer a library project in yout android project

Right click on your android project, goto properties, choose android, click add, browse and add the library project. Click apply and ok.

Snap shot of adding actionbaesherlock library project. Note the green tick.

Clean and build.

http://developer.android.com/tools/projects/projects-eclipse.html




回答2:


There is no way to encapsulate Android resources into a Jar file. The only way to achieve that is adding your library project to the build path of your application. If you are using Eclipse simply right click your project -> properties -> Java Build Path -> Projects and add your library here.



来源:https://stackoverflow.com/questions/16341439/android-library-project-resourcesnotfoundexception

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!