Domanda

I have 2 android projects:

  • 1 library project used as an API in several other projects and generating an apklib
  • 2 android projects using this apklib

In my apklib project I have in one layout a referenced spinner R.id.mySpinner

I have one androidproject compiling well in eclipse and maven (using mvn clean install). Remark: This first projects use also in one layout the same reference on a spinner R.id.mySpinner.

The second android project compiles well under eclipse but when compiling with maven I have following ERROR:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile) on project myproject: Compilation failure: Compilation failure:
[ERROR] /mypath/target/unpack/apklibs/mylibpackage/src/pathtoactivity/BaseActivity.java:[302,79] cannot find symbol
[ERROR] symbol:   variable mySpinner
[ERROR] location: class mypackage.R.id

I noted that as said by the compiler the R generated by maven compiler in directory ..\target\generated-sources\r\mypackage\R.java do not contains mySpinner reference unlike in the project compiling well.

Remark: This second project DO NOT have any reference to R.id.mySpinner in any of its class or layout.

So here am I, I don't know were to search anymore. The only difference I noted between the two projects is the remarked noted above. I don't know what's the diffrence beween the eclipse compilation and the mvn compilation either.

Someone has ever encontered such a problem? Or do you have a tip to find somewhere information setting me on the way to the solution?

È stato utile?

Soluzione

I finally found the problem myself. The problem was that a layout had the same name in both the Android program project and the apklib project. As a consequence the layout containing the reference to mypackage.R.id in the apkklib project was overridden.

In my case that was the main.xml layout of the library that was overridden by the main.xml layout created by eclipse for the "hello world" project and that I forgot to remove.

Maven was detecting it at compilation time while the Eclipse plugin wasn't, again a bug.

Removing the clandestine "hello world" main.xml from the Android project fixed it.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top