Two android projects in one: ID Conflicts

1

I have a solution with two android projects.

One, it's a normal project (which can be compiled) but I intend to use it as a library. Let's call it "PLIB".

Another is a normal application, which refers to this library project to implement its classes, functions and resources. I'll call it "PAPP".

So far so good.

The problem is that PLIB, has a layout "Library.axml" that corresponds to the ID "2130903040" in the Resource.designer.cs

When I compile the "PAPP" project, it has a "Main.axml" layout that also corresponds to the ID "2130903040".

Then, when the PLIB code tries to use the resource "Resource.Layout.Library" as it has the same ID "2130903040", instead of finding "Library.axml" it finds "Main.axml".

How could I force the IDs of the resources to both projects never coincide and so it works?

    
asked by OMendoza 13.10.2016 в 14:44
source

2 answers

0

The PAPP resources will always have priority over the PLIB resources, therefore, I recommend you change the identifiers of the resources with a prefix, something like "PLIB_name_of_your_recurso"

    
answered by 13.10.2016 в 16:46
0

What you are saying is true, two similar ids are generated when there are two resources with the same name, which can be seen within the files R.java of the projects.

But it is important to comment that this does not generate any type of conflict, the resource that loads the application would be by priority the one that loads the application.

In the case you mention are two different resources, which should generate two different ids.

I suggest you make a Build > Clean Project and compile your project again, you must generate a different id within R.java for each resource since your application and your library when compiling are considered as a single project.

Sometimes we see that they do not change the id but that can be caused by another factor such as having a problem with some resource, I give you some tips:

  • The name of a resource contains a capital letter, ensures that the names of the resources are specified in lowercase.
  • .xml resources refer to a resource that does not exist.

One of the projects must be defined as a library, dependent on the main project. If they are two different projects, you would have to rename the resource in one of the 2

    
answered by 13.10.2016 в 16:49