Packaging Android resource files within a distributable Jar file

后端 未结 9 2297
自闭症患者
自闭症患者 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:08

    I don't have any optimistic news for you. In general you cannot distribute your own package as easily as you would expect. The main problem is the autogenerated R file. You probably make some references to it - you have your layouts and drawables. User of your library will have his own R file - containing ids for his resources, not for the ones your library provides.

    In case of drawable resources you could read them in classic way, without R file. But as far as I know you are not able to inflate layouts from external xml files.

    So the ugly hack here would be to distribute your library together with all your resources, which user would have to copy to his "res" folder. To be honest, there is no good solution to your problem... sorry. Regards!

提交回复
热议问题