Packaging Android resource files within a distributable Jar file

后端 未结 9 2294
自闭症患者
自闭症患者 2020-11-28 18:26

I am working on some reusable Android code that I would like to distribute to other developers for use within their own applications. The code has some resource dependencies

9条回答
  •  臣服心动
    2020-11-28 19:11

    I was using user558185 solution but here is a more simple way. If you resources is in a library project (for a Cordova Plugin for example), you can get resource with context.getResources().getIdentifier(name, className, context.getPackageName());

    This happen when the library project resources R file is not generated properly and the R packageName did not match the required packageName by the library project.

    The usage is the same as user558185 answer, but it use a native Android method.

提交回复
热议问题