i'm trying to understand Maven Android Plugin with the examples found here: https://github.com/jayway/maven-android-plugin-samples/archives/stable
I'm using the example "libraryproject" and all is working good, only one thing i really can't figure out: if i change something into the lib1 project (example the content of the resource file) and complile the main project, i still see in the generated apk file the old resources.
I tryed to clean, rebuild, no change in my apk...
Sorry for the stupid question end for my bad english.
EDIT: i just did like said by yorkw:
But now i receive the following error:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Library Projects Parent
[INFO] Library Projects - Library 1
[INFO] Library Projects - Library 2
[INFO] Library Projects - Main App
[INFO] Library Projects - Instrumentation Tests
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Library Projects Parent 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Library Projects - Library 1 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- android-maven-plugin:3.1.1:generate-sources (default-generate-sources) @ libraryprojects-lib1 ---
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] C:\Program Files (x86)\Android\android-sdk-windows\platform-tools\aapt.exe [package, -m, -J, C:\Users\nicola\Desktop\maven_example\jayway-maven-android-plugin-samples-c475bf4\libraryprojects\libraryprojects-lib1\target\generated-sources\r, -M, C:\Users\nicola\Desktop\maven_example\jayway-maven-android-plugin-samples-c475bf4\libraryprojects\libraryprojects-lib1\AndroidManifest.xml, -S, C:\Users\nicola\Desktop\maven_example\jayway-maven-android-plugin-samples-c475bf4\libraryprojects\libraryprojects-lib1\res, --auto-add-overlay, -A, C:\Users\nicola\Desktop\maven_example\jayway-maven-android-plugin-samples-c475bf4\libraryprojects\libraryprojects-lib1\assets, -I, C:\Program Files (x86)\Android\android-sdk-windows\platforms\android-10\android.jar]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Library Projects - Library 2 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- android-maven-plugin:3.1.1:generate-sources (default-generate-sources) @ libraryprojects-lib2 ---
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] C:\Program Files (x86)\Android\android-sdk-windows\platform-tools\aapt.exe [package, -m, -J, C:\Users\nicola\Desktop\maven_example\jayway-maven-android-plugin-samples-c475bf4\libraryprojects\libraryprojects-lib2\target\generated-sources\r, -M, C:\Users\nicola\Desktop\maven_example\jayway-maven-android-plugin-samples-c475bf4\libraryprojects\libraryprojects-lib2\AndroidManifest.xml, -S, C:\Users\nicola\Desktop\maven_example\jayway-maven-android-plugin-samples-c475bf4\libraryprojects\libraryprojects-lib2\res, --auto-add-overlay, -A, C:\Users\nicola\Desktop\maven_example\jayway-maven-android-plugin-samples-c475bf4\libraryprojects\libraryprojects-lib2\assets, -I, C:\Program Files (x86)\Android\android-sdk-windows\platforms\android-10\android.jar]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Library Projects - Main App 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- android-maven-plugin:3.1.1:generate-sources (default-generate-sources) @ libraryprojects-mainapp ---
[DEBUG] Expanding: C:\Users\nicola\.m2\repository\com\jayway\maven\plugins\android\generation2\samples\libraryprojects\libraryprojects-lib1\1.0.0-SNAPSHOT\libraryprojects-lib1-1.0.0-SNAPSHOT.apklib into C:\Users\nicola\Desktop\maven_example\jayway-maven-android-plugin-samples-c475bf4\libraryprojects\libraryprojects-mainapp\target\unpack\apklibs\com.jayway.maven.plugins.android.generation2.samples.libraryprojects_libraryprojects-lib1_apklib_1.0.0-SNAPSHOT
[DEBUG] expand complete
[DEBUG] Expanding: C:\Users\nicola\.m2\repository\com\jayway\maven\plugins\android\generation2\samples\libraryprojects\libraryprojects-lib2\1.0.0-SNAPSHOT\libraryprojects-lib2-1.0.0-SNAPSHOT.apklib into C:\Users\nicola\Desktop\maven_example\jayway-maven-android-plugin-samples-c475bf4\libraryprojects\libraryprojects-mainapp\target\unpack\apklibs\com.jayway.maven.plugins.android.generation2.samples.libraryprojects_libraryprojects-lib2_apklib_1.0.0-SNAPSHOT
[DEBUG] expand complete
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] C:\Program Files (x86)\Android\android-sdk-windows\platform-tools\aapt.exe [package, -m, -J, C:\Users\nicola\Desktop\maven_example\jayway-maven-android-plugin-samples-c475bf4\libraryprojects\libraryprojects-mainapp\target\generated-sources\r, -M, C:\Users\nicola\Desktop\maven_example\jayway-maven-android-plugin-samples-c475bf4\libraryprojects\libraryprojects-mainapp\AndroidManifest.xml, -S, C:\Users\nicola\Desktop\maven_example\jayway-maven-android-plugin-samples-c475bf4\libraryprojects\libraryprojects-mainapp\res, -S, C:\Users\nicola\Desktop\maven_example\jayway-maven-android-plugin-samples-c475bf4\libraryprojects\libraryprojects-mainapp\target\unpack\apklibs/com.jayway.maven.plugins.android.generation2.samples.libraryprojects_libraryprojects-lib1_apklib_1.0.0-SNAPSHOT/res, -S, C:\Users\nicola\Desktop\maven_example\jayway-maven-android-plugin-samples-c475bf4\libraryprojects\libraryprojects-mainapp\target\unpack\apklibs/com.jayway.maven.plugins.android.generation2.samples.libraryprojects_libraryprojects-lib2_apklib_1.0.0-SNAPSHOT/res, --auto-add-overlay, -I, C:\Program Files (x86)\Android\android-sdk-windows\platforms\android-10\android.jar]
[INFO] C:\Users\nicola\Desktop\maven_example\jayway-maven-android-plugin-samples-c475bf4\libraryprojects\libraryprojects-mainapp\res\layout\main.xml:12: error: Error: No resource found that matches the given name (at 'text' with value '@string/lib1resource').
[INFO] C:\Users\nicola\Desktop\maven_example\jayway-maven-android-plugin-samples-c475bf4\libraryprojects\libraryprojects-mainapp\res\layout\main.xml:17: error: Error: No resource found that matches the given name (at 'text' with value '@string/lib2resource').
[ERROR] Error when generating sources.
org.apache.maven.plugin.MojoExecutionException:
at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.generateR(GenerateSourcesMojo.java:338)
at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.execute(GenerateSourcesMojo.java:102)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: com.jayway.maven.plugins.android.ExecutionException: ANDROID-040-001: Could not execute: Command = cmd.exe /X /C ""C:\Program Files (x86)\Android\android-sdk-windows\platform-tools\aapt.exe" package -m -J C:\Users\nicola\Desktop\maven_example\jayway-maven-android-plugin-samples-c475bf4\libraryprojects\libraryprojects-mainapp\target\generated-sources\r -M C:\Users\nicola\Desktop\maven_example\jayway-maven-android-plugin-samples-c475bf4\libraryprojects\libraryprojects-mainapp\AndroidManifest.xml -S C:\Users\nicola\Desktop\maven_example\jayway-maven-android-plugin-samples-c475bf4\libraryprojects\libraryprojects-mainapp\res -S C:\Users\nicola\Desktop\maven_example\jayway-maven-android-plugin-samples-c475bf4\libraryprojects\libraryprojects-mainapp\target\unpack\apklibs/com.jayway.maven.plugins.android.generation2.samples.libraryprojects_libraryprojects-lib1_apklib_1.0.0-SNAPSHOT/res -S C:\Users\nicola\Desktop\maven_example\jayway-maven-android-plugin-samples-c475bf4\libraryprojects\libraryprojects-mainapp\target\unpack\apklibs/com.jayway.maven.plugins.android.generation2.samples.libraryprojects_libraryprojects-lib2_apklib_1.0.0-SNAPSHOT/res --auto-add-overlay -I "C:\Program Files (x86)\Android\android-sdk-windows\platforms\android-10\android.jar"", Result = 1
at com.jayway.maven.plugins.android.CommandExecutor$Factory$1.executeCommand(CommandExecutor.java:215)
at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.generateR(GenerateSourcesMojo.java:336)
... 22 more
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Library Projects Parent ........................... SUCCESS [0.004s]
[INFO] Library Projects - Library 1 ...................... SUCCESS [1.109s]
[INFO] Library Projects - Library 2 ...................... SUCCESS [0.299s]
[INFO] Library Projects - Main App ....................... FAILURE [0.489s]
[INFO] Library Projects - Instrumentation Tests .......... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.277s
[INFO] Finished at: Wed Apr 18 02:46:34 CEST 2012
[INFO] Final Memory: 5M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.1.1:generate-sources (default-generate-sources) on project libraryprojects-mainapp: MojoExecutionException: ANDROID-040-001: Could not execute: Command = cmd.exe /X /C ""C:\Program Files (x86)\Android\android-sdk-windows\platform-tools\aapt.exe" package -m -J C:\Users\nicola\Desktop\maven_example\jayway-maven-android-plugin-samples-c475bf4\libraryprojects\libraryprojects-mainapp\target\generated-sources\r -M C:\Users\nicola\Desktop\maven_example\jayway-maven-android-plugin-samples-c475bf4\libraryprojects\libraryprojects-mainapp\AndroidManifest.xml -S C:\Users\nicola\Desktop\maven_example\jayway-maven-android-plugin-samples-c475bf4\libraryprojects\libraryprojects-mainapp\res -S C:\Users\nicola\Desktop\maven_example\jayway-maven-android-plugin-samples-c475bf4\libraryprojects\libraryprojects-mainapp\target\unpack\apklibs/com.jayway.maven.plugins.android.generation2.samples.libraryprojects_libraryprojects-lib1_apklib_1.0.0-SNAPSHOT/res -S C:\Users\nicola\Desktop\maven_example\jayway-maven-android-plugin-samples-c475bf4\libraryprojects\libraryprojects-mainapp\target\unpack\apklibs/com.jayway.maven.plugins.android.generation2.samples.libraryprojects_libraryprojects-lib2_apklib_1.0.0-SNAPSHOT/res --auto-add-overlay -I "C:\Program Files (x86)\Android\android-sdk-windows\platforms\android-10\android.jar"", Result = 1 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :libraryprojects-mainapp
You should build the project (mvn clean install) in the parent project folder (../libraryprojects), this will build libraryprojects-lib1 project (so that latest apklib is installed into your local maven repository) along with libraryprojects-mainapp project.
If you build the project (mvn clean install) in the sub project folder (../libraryprojects/libraryprojects-mainapp), this will build only the libraryprojects-mainapp and using the existing apklib stored in your local maven repository for project dependency. In another word, the libraryprojects-lib1 project re-build doesn't occurred and contribute to the build life cycle of libraryprojects-mainapp project.
Note that if you import the whole project in Eclipse and clean/build libraryprojects-mainapp by Eclipse, it will automatically trigger re-build process for the dependent library project libraryprojects-lib1.
Update:
I have downloaded latest android maven plugin and give it a try on my Windows XP box and replicate the problem, it is actually a Microsoft Fault! If you try to access (this is one of temp folder Maven created when build you project):
C:\Users\nicola\Desktop\maven_example\jayway-maven-android-plugin-samples-c475bf4\libraryprojects\libraryprojects-mainapp\target\unpack\apklibs\com.jayway.maven.plugins.android.generation2.samples.libraryprojects_libraryprojects-lib2_apklib_1.0.0-SNAPSHOT\res
from Explorer, you get:
Check out here and here for more details. Maximum Path Length Limitation on Windows is 256 characters.
Solution:
First of all, try using a short path, for instance, the following would be find:
C:\c475bf4\libraryprojects\libraryprojects-mainapp\target\unpack\apklibs\com.jayway.maven.plugins.android.generation2.samples.libraryprojects_libraryprojects-lib2_apklib_1.0.0-SNAPSHOT\res
Then give it another try and see if you can build it, you will probably get another build error (I tried on my Windows XP box and get this error) as below:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.1:compile (default-compile) on project libraryprojects-mainapp: Compilation failure: Compilation failure:
[ERROR] C:\c475bf4\libraryprojects\libraryprojects-mainapp\src\main\java\com\jayway\maven\plugins\android\generation2\samples\libraryprojects\mainapp\MainActivity.java:[16,5] annotations are not supported in -source 1.3
To fix this, you can specify a later version of maven-compiler-plugin in ..\libraryprojects\pom.xml:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
Last but not least, note that you need open an emulator in order to let the test sub project to run instrumentation test, otherwise build test project will be fail.
Hope this helps.