kingdom578 / maven-android-plugin

Automatically exported from code.google.com/p/maven-android-plugin
0 stars 0 forks source link

Compilation error when referencing resources from dependency libraries #296

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Download the "Samples" from 
http://code.google.com/p/maven-android-plugin/wiki/Samples
2. Fire up Eclipse and import the "LibraryProjects" into a new workspace
3. run mvn clean install on the "library-projects-mainapp"

What is the expected output?
The projects can be built successfully.

What do you see instead?

INFO] C:\work\workspaces\android-sdk-windows\platform-tools\aapt.exe [package, 
-m, -J, 
C:\Users\nick\Downloads\jayway-maven-android-plugin-samples-36a5a69\libraryproje
cts\libraryprojects-mainapp\target\generated-sources\r, -M, 
C:\Users\nick\Downloads\jayway-maven-android-plugin-samples-36a5a69\libraryproje
cts\libraryprojects-mainapp\AndroidManifest.xml, -S, 
C:\Users\nick\Downloads\jayway-maven-android-plugin-samples-36a5a69\libraryproje
cts\libraryprojects-mainapp\res, -S, 
C:\Users\nick\Downloads\jayway-maven-android-plugin-samples-36a5a69\libraryproje
cts\libraryprojects-mainapp\target\unpack\apklibs/com.jayway.maven.plugins.andro
id.generation2.samples.libraryprojects_libraryprojects-lib1_apklib_1.0.0-SNAPSHO
T/res, -S, 
C:\Users\nick\Downloads\jayway-maven-android-plugin-samples-36a5a69\libraryproje
cts\libraryprojects-mainapp\target\unpack\apklibs/com.jayway.maven.plugins.andro
id.generation2.samples.libraryprojects_libraryprojects-lib2_apklib_1.0.0-SNAPSHO
T/res, --auto-add-overlay, -I, 
C:\work\workspaces\android-sdk-windows\platforms\android-10\android.jar]
[INFO] 
C:\Users\nick\Downloads\jayway-maven-android-plugin-samples-36a5a69\libraryproje
cts\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\nick\Downloads\jayway-maven-android-plugin-samples-36a5a69\libraryproje
cts\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(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    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:\work\workspaces\android-sdk-windows\platform-tools\aapt.exe package -m -J 
C:\Users\nick\Downloads\jayway-maven-android-plugin-samples-36a5a69\libraryproje
cts\libraryprojects-mainapp\target\generated-sources\r -M 
C:\Users\nick\Downloads\jayway-maven-android-plugin-samples-36a5a69\libraryproje
cts\libraryprojects-mainapp\AndroidManifest.xml -S 
C:\Users\nick\Downloads\jayway-maven-android-plugin-samples-36a5a69\libraryproje
cts\libraryprojects-mainapp\res -S 
C:\Users\nick\Downloads\jayway-maven-android-plugin-samples-36a5a69\libraryproje
cts\libraryprojects-mainapp\target\unpack\apklibs/com.jayway.maven.plugins.andro
id.generation2.samples.libraryprojects_libraryprojects-lib1_apklib_1.0.0-SNAPSHO
T/res -S 
C:\Users\nick\Downloads\jayway-maven-android-plugin-samples-36a5a69\libraryproje
cts\libraryprojects-mainapp\target\unpack\apklibs/com.jayway.maven.plugins.andro
id.generation2.samples.libraryprojects_libraryprojects-lib2_apklib_1.0.0-SNAPSHO
T/res --auto-add-overlay -I 
C:\work\workspaces\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

What version of maven-android-plugin are you using?

 3.3.0

What are the complete output lines of "mvn -version" on your machine?

Apache Maven 3.0.4 (r1232337; 2012-01-17 15:44:56+0700)
Maven home: 
C:\Users\nick\Downloads\jayway-maven-android-plugin-samples-36a5a69\libraryproje
cts\EMBEDDED
Java version: 1.6.0_23, vendor: Sun Microsystems Inc.
Java home: C:\Program Files\Java\jre6
Default locale: en_US, platform encoding: Cp1252
OS name: "windows server 2008 r2", version: "6.1", arch: "amd64", family: 
"windows"

Please provide any additional information below.

a)
Initially I saw this on a Helios Eclipse but did a fresh Juno 64bit 
installation with

- Latest ADT (SDK Tools 20.0.1, Platform tools 14)

- Latest m2eclipse (3.0.4)

- Latest android m2e (0.4.2)

and yes, I use android-maven-plugin 3.3.0

b)
I changed the Android API level from 8 to 10 in the sample but this shouldn't 
make a difference.

c)
I get the same errors when I run appt from the command line:
- command line

c:\Program Files\TortoiseSVN\bin>cmd.exe /X /C 
"C:\work\workspaces\android-sdk-windows\platform-tools\aapt.exe package -m -J 
C:\Users\nick\Downloads\j
ayway-maven-android-plugin-samples-36a5a69\libraryprojects\libraryprojects-maina
pp\target\generated-sources\r -M C:\Users\nick\Downloads\jayway-maven-
android-plugin-samples-36a5a69\libraryprojects\libraryprojects-mainapp\AndroidMa
nifest.xml -S C:\Users\nick\Downloads\jayway-maven-android-plugin-samp
les-36a5a69\libraryprojects\libraryprojects-mainapp\res -S 
C:\Users\nick\Downloads\jayway-maven-android-plugin-samples-36a5a69\libraryproje
cts\library
projects-mainapp\target\unpack\apklibs/com.jayway.maven.plugins.android.generati
on2.samples.libraryprojects_libraryprojects-lib1_apklib_1.0.0-SNAPSHOT
/res -S 
C:\Users\nick\Downloads\jayway-maven-android-plugin-samples-36a5a69\libraryproje
cts\libraryprojects-mainapp\target\unpack\apklibs/com.jayway.m
aven.plugins.android.generation2.samples.libraryprojects_libraryprojects-lib2_ap
klib_1.0.0-SNAPSHOT/res --auto-add-overlay -I C:\work\workspaces\andro
id-sdk-windows\platforms\android-10\android.jar"
C:\Users\nick\Downloads\jayway-maven-android-plugin-samples-36a5a69\libraryproje
cts\libraryprojects-mainapp\res\layout\main.xml:12: error: Error: No r
esource found that matches the given name (at 'text' with value 
'@string/lib1resource').
C:\Users\nick\Downloads\jayway-maven-android-plugin-samples-36a5a69\libraryproje
cts\libraryprojects-mainapp\res\layout\main.xml:17: error: Error: No r
esource found that matches the given name (at 'text' with value 
'@string/lib2resource').

Original issue reported on code.google.com by dominik....@gmail.com on 9 Aug 2012 at 9:59

GoogleCodeExporter commented 9 years ago
The same errors also occur when I run Maven outside eclipse

Original comment by dominik....@gmail.com on 13 Aug 2012 at 2:01

GoogleCodeExporter commented 9 years ago
Logfile

Original comment by dominik....@gmail.com on 13 Aug 2012 at 2:01

Attachments:

GoogleCodeExporter commented 9 years ago
See https://github.com/rgladwell/m2e-android/issues/101

the m2e-android people suspect this to be an android-maven-plugin issue.

Original comment by dominik....@gmail.com on 13 Aug 2012 at 8:09

GoogleCodeExporter commented 9 years ago
I have a similar issue. But in my case aapt.exe can't find resources from the 
main project.

Excerpt from the console output when executing mvn clean package command:

[INFO] D:\dev\android-sdk-windows\platform-tools\aapt.exe [package, -m, -J, 
M:\projects\android\marsrutai-lt-mobile\mars
rutai-lt-app\target\generated-sources\r, -M, 
M:\projects\android\marsrutai-lt-mobile\marsrutai-lt-app\AndroidManifest.xm
l, -S, 
M:\projects\android\marsrutai-lt-mobile\marsrutai-lt-app\target\unpack\apklibs/c
om.actionbarsherlock_library_apkl
ib_4.1.0/res, --auto-add-overlay, -A, 
M:\projects\android\marsrutai-lt-mobile\marsrutai-lt-app\assets, -I, 
D:\dev\androi
d-sdk-windows\platforms\android-15\android.jar]
[INFO] 
M:\projects\android\marsrutai-lt-mobile\marsrutai-lt-app\AndroidManifest.xml:11:
 error: Error: No resource found
that matches the given name (at 'icon' with value '@drawable/icon').
[INFO] 
M:\projects\android\marsrutai-lt-mobile\marsrutai-lt-app\AndroidManifest.xml:11:
 error: Error: No resource found
that matches the given name (at 'label' with value '@string/app_name').
[INFO] 
M:\projects\android\marsrutai-lt-mobile\marsrutai-lt-app\AndroidManifest.xml:15:
 error: Error: No resource found
that matches the given name (at 'label' with value '@string/app_name').
[INFO] 
M:\projects\android\marsrutai-lt-mobile\marsrutai-lt-app\AndroidManifest.xml:32:
 error: Error: No resource found
that matches the given name (at 'resource' with value '@xml/searchable_stops').
[INFO] 
M:\projects\android\marsrutai-lt-mobile\marsrutai-lt-app\AndroidManifest.xml:42:
 error: Error: No resource found
that matches the given name (at 'theme' with value '@style/Theme.Marsrutai').

It seems that -S parameter is only provided for apklib dependency resources. 
Are main app resources included by default, or is this parameter missing?

Original comment by MMarty...@gmail.com on 26 Aug 2012 at 6:41

GoogleCodeExporter commented 9 years ago
Indeed, when I added second -S parameter manually, which points to the main app 
resource directory, aapt.exe executed normally without any errors.

Any idea, why this parameter is not added automatically?

Original comment by MMarty...@gmail.com on 26 Aug 2012 at 6:45

GoogleCodeExporter commented 9 years ago
It was a project misconfiguration. Sorry about spam. |:

FYI this change broke the build (lines 158-172):
http://code.google.com/p/marsrutai-lt-mobile/source/diff?spec=svn379&r=379&forma
t=side&path=/marsrutai-lt-mobile/trunk/marsrutai-lt-app/pom.xml

Original comment by MMarty...@gmail.com on 26 Aug 2012 at 6:53

GoogleCodeExporter commented 9 years ago
My workaround is to cut a path to the project. For example, I had rename parent 
folder of project from "ayway-maven-android-plugin-samples-81169dd" to 
"ayway-samples-81169dd". After that I can build project.

Mu full path to parent folder after renaming is:
D:\projects\android\jayway-samples-81169dd.

Here, one guy wrote about Microsoft Windows problem, which is trouble with long 
name of file path.
http://stackoverflow.com/questions/10200813/updating-a-maven-library-project-int
o-main-project-android

I try to rename and it's working!!! 
Good luck.

Original comment by ya.sanch...@gmail.com on 4 Feb 2013 at 4:18

GoogleCodeExporter commented 9 years ago
Hi all
I m facing the same problem but only in Jenkins

perhaps the problem is Jenkins plugins for maven-android ?

someone had the same issue >

CONSOLE OUTPUT:
...
Parsing POMs
Modules changed, recalculating dependency graph
[workspace] $ "C:\Program Files\Java\jdk1.6.0_31/bin/java" -cp 
C:\Users\User\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven3-agent-1.2.jar;C:\
apache-maven-3.0.4\boot\plexus-classworlds-2.4.jar 
org.jvnet.hudson.maven3.agent.Maven3Main C:\apache-maven-3.0.4 
C:\Tomcat6\webapps\jenkins\WEB-INF\lib\remoting-2.21.jar 
C:\Users\User\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven3-interceptor-1.2.j
ar 65237
<===[JENKINS REMOTING CAPACITY]===>channel started
log4j:WARN No appenders could be found for logger 
(org.apache.commons.beanutils.converters.BooleanConverter).
log4j:WARN Please initialize the log4j system properly.
Executing Maven:  -B -f 
C:\Users\User\.jenkins\jobs\MyMobile-app\workspace\pom.xml -gs 
C:\Users\User\.m2\settingsAndroid.xml install
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building MyMobile-app 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- android-maven-plugin:3.1.1:generate-sources 
(default-generate-sources) @ MyMobile-app ---
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] C:\temp\android-sdk-windows\platform-tools\aapt.exe [package, -m, -J, 
C:\Users\User\.jenkins\jobs\MyMobile-app\workspace\target\generated-sources\r, 
-M, C:\Users\User\.jenkins\jobs\MyMobile-app\workspace\AndroidManifest.xml, 
--auto-add-overlay, -I, 
C:\temp\android-sdk-windows\platforms\android-17\android.jar]
[INFO] C:\Users\User\.jenkins\jobs\MyMobile-app\workspace\AndroidManifest.xml: 
error: Unable to open file for read: No such file or directory
[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.jvnet.hudson.maven3.launcher.Maven3Launcher.main(Maven3Launcher.java:79)
    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.launchStandard(Launcher.java:329)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:239)
    at org.jvnet.hudson.maven3.agent.Maven3Main.launch(Maven3Main.java:158)
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:100)
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:66)
    at hudson.remoting.UserRequest.perform(UserRequest.java:118)
    at hudson.remoting.UserRequest.perform(UserRequest.java:48)
    at hudson.remoting.Request$2.run(Request.java:326)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: com.jayway.maven.plugins.android.ExecutionException: 
ANDROID-040-001: Could not execute: Command = cmd.exe /X /C 
"C:\temp\android-sdk-windows\platform-tools\aapt.exe package -m -J 
C:\Users\User\.jenkins\jobs\MyMobile-app\workspace\target\generated-sources\r 
-M C:\Users\User\.jenkins\jobs\MyMobile-app\workspace\AndroidManifest.xml 
--auto-add-overlay -I 
C:\temp\android-sdk-windows\platforms\android-17\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)
    ... 30 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE

Original comment by ramon00...@gmail.com on 28 Feb 2013 at 11:36

GoogleCodeExporter commented 9 years ago
We are no longer using the issue tracking system on Google Code. Please refile 
this issue on https://github.com/jayway/maven-android-plugin/issues if you 
still have this problem with the latest release of the Android Maven Plugin

Original comment by mosa...@gmail.com on 19 May 2014 at 4:18