Reputation: 11
I am currently working on a Android Project where we are expected to merge our App with 2 more apps from vendors who wouldn't be sharing their code.So just wanted to know Is there any way we could just include there Source code as JAR Files in our project and then include their resources and point to them(I did do it using getResources().getIdentifier("splash", "layout", getPackageName()) But Its still not working ?? I think I have tried all possible methods so hoping you guys could help me with this.
Upvotes: 1
Views: 483
Reputation: 511
In order to support faster build times, the r16 tools are creating their own jar files inside of Android Library Projects. You can use this feature to solve this issue. If a vendor would like to release their Android Library Project but without source code, they can make a copy of that Android Library Project that contains everything except for the source code tree. Next, include the jar file from the original Android Library Porject (the one that the r16 tools built.) This will allow you to have a component you can distribute that does not require source code. The consumer of this new Android Library Project will need to manually add any necessary meta data to their own project's AndroidManifest.xml file as needed (Activities, Providers, Permissions, etc).
Upvotes: 0
Reputation: 11
The Activities can be compiled into a jar and added to the main Android project and we need to add their project's resources into your Project. The only we could make it work is using the getResources().getIdentifier("splash", "layout", getPackageName())
. Even the Widgets like TextView
, Button
and all those should be referred to using the getResources()
method. Like, for example, If you want to perform a action on particular button then we need to identify them by getResources().getIdentifier("Button" /*id in the XML File*/, "id"/*type*/, getPackageName())
.
One more thing: you need to specify all the Activities in your Main Android Project's AndroidManifest.xml
file with their package name. I hope this solves something.
Upvotes: 0
Reputation: 5980
To quote CommonsWare from this question:
Bear in mind that your packaged classes cannot reference resources (at least not via R. syntax), and that JARs cannot package resources, manifest entries, etc. If all you are trying to JAR up is pure Java code (perhaps using Android APIs), then you should be fine.
Basically, you can only use JARs that contain pure java as libraries in your app, not entire other projects.
Upvotes: 1