Java Android Merging Projects

Asked

Viewed 692 times

1

Sometimes I need to use one project in another like a UI framework in my application or something like that and most of them are available in repositories like github etc, I usually download and extract the files to my project folder but soon the eclipse starts to alert several errors usually for two reasons

  1. Import it from the class R the package is wrong or is it usually refers to the original package of the framework not to mine project (Thing Obvia rsrs)
  2. The class R does not identify Resources and they often stay inaccessible

I believe that I am probably embedding one project in the other wrong way I would like to know how I can do it in a simple way, every time I decide to use some UI Framework is a Erra I need to fix all these errors at hand.

  • Could you answer the following questions? Are you placing the library fonts directly in your project (module)? Which IDE is using (Eclipse, Android Studio or other)? Which build system (ant, Gradle or Maven)? It could also include the link of one of these Ibraries?

  • I’m using Eclipse my build system is the eclipse pattern, I’m putting the fonts right into the project, the classes and the xml layout files, one of the projects I’m including is this https://github.com/JakeWharton/ActionBarSherlock

  • As I do not use Eclipse for Android development, I can not generate a satisfactory answer. But I leave my contribution: Whenever you check out a library repository, try to create a separate Eclipse (module) project for it (having your own folder res and your own AndroidManifest), with this you already avoid problems with references to class R, because each project has one. Take a look at http://www.simpligility.com/2010/07/multi-module-android-project-in-eclipse/. More...

  • Eclipse uses Ant to build and generate APK. I think it is possible to use Maven to manage your dependencies, I say this because many Maven modules (e.g : https://github.com/ManuelPeinado/GlassActionBar) submit modules to Maven Repository, using Maven or Gradle it is very easy to include in your code (https://gist.github.com/wakim/42ee30ceb958a3f80110), thus avoiding the problem of use.

  • When starting a new Android project, from a look at Android Studio, may be personal opinion but never go back to Eclipse after I changed, no comparison.

  • @Wakim actually I also prefer the Android Studio rs I chose to use the eclipse because these library were with the eclipse build. Thanks for the tips.

Show 1 more comment

1 answer

1

Add the project as a module of your main application (the one that will make use of the Resources) and mark to be compiled together with the project.

This will allow you to access the included project class files.

To allow access to Resources it is also necessary to add to project folder included as module in the solution of the main project.

Then getting 2 folders in your IDE:

Minha Aplicacao:
Projeto Principal/
Projeto Incluido/

Exemplo de como vai ficar, no caso estou usando 2 libs

Make sure the enclosed project is marked as Library.

All these options you find in your project/solution properties.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.