使用Maven构buildAndroid项目时出错

我正在尝试使用Maven构build我的Android项目,这样我就可以自动执行testing,但出现以下错误:

D:\Projects\mtproject>mvn install [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building AppScience 1.0.0 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-android-plugin:2.8.4:generate-sources (default-generate-sources) @ appsci ence --- [INFO] ANDROID-904-002: Found aidl files: Count = 3 [INFO] ANDROID-904-002: Found aidl files: Count = 0 [INFO] Copying local resource files to combined resource directory. [INFO] C:\Program Files (x86)\Android\android-sdk/platform-tools/aapt.exe [package, -m, -J , D:\Projects\mtproject\target\generated-sources\r, -M, D:\Projects\mtproject\AndroidManif est.xml, -S, D:\Projects\mtproject\target\generated-sources\combined-resources\res, -A, D: \Projects\mtproject\assets, -I, C:\Program Files (x86)\Android\android-sdk\platforms\andro id-4\android.jar] [INFO] D:\Projects\mtproject\target\generated-sources\combined-resources\res\layout\main.x ml:2: error: Error: String types not allowed (at 'layout_height' with value 'match_parent' ). [INFO] D:\Projects\mtproject\target\generated-sources\combined-resources\res\layout\main.x ml:2: error: Error: String types not allowed (at 'layout_width' with value 'match_parent') . [INFO] D:\Projects\mtproject\target\generated-sources\combined-resources\res\layout\main.x ml:5: error: Error: String types not allowed (at 'layout_width' with value 'match_parent') . [INFO] D:\Projects\mtproject\target\generated-sources\combined-resources\res\layout\main.x ml:11: error: Error: String types not allowed (at 'layout_width' with value 'match_parent' ). [INFO] D:\Projects\mtproject\target\generated-sources\combined-resources\res\layout\splash .xml:2: error: Error: String types not allowed (at 'layout_width' with value 'match_parent '). [INFO] D:\Projects\mtproject\target\generated-sources\combined-resources\res\layout\splash .xml:2: error: Error: String types not allowed (at 'layout_height' with value 'match_paren t'). [ERROR] Error when generating sources. org.apache.maven.plugin.MojoExecutionException: at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.gen erateR(GenerateSourcesMojo.java:313) at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.exe cute(GenerateSourcesMojo.java:111) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPlugi nManager.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(Lifecyc leModuleBuilder.java:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(Lifecyc leModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(Lifecy cleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.j ava:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319) 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.ja va: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.jav a: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\platform-to ols\aapt.exe" package -m -JD:\Projects\mtproject\target\generated-sources\r -MD:\Project s\mtproject\AndroidManifest.xml -SD:\Projects\mtproject\target\generated-sources\combined -resources\res -AD:\Projects\mtproject\assets -I "C:\Program Files (x86)\Android\android- sdk\platforms\android-4\android.jar"", Result = 1 at com.jayway.maven.plugins.android.CommandExecutor$Factory$1.executeCommand(Comma ndExecutor.java:186) at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.gen erateR(GenerateSourcesMojo.java:311) ... 22 more [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 19.558s [INFO] Finished at: Fri Aug 26 04:00:16 CEST 2011 [INFO] Final Memory: 7M/45M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal com.jayway.maven.plugins.android.generation2:maven-android- plugin:2.8.4:generate-sources (default-generate-sources) on project appscience: MojoExecut ionException: ANDROID-040-001: Could not execute: Command = cmd.exe /X /C ""C:\Program Fil es (x86)\Android\android-sdk\platform-tools\aapt.exe" package -m -JD:\Projects\mtproject\ target\generated-sources\r -MD:\Projects\mtproject\AndroidManifest.xml -SD:\Projects\mtp roject\target\generated-sources\combined-resources\res -AD:\Projects\mtproject\assets -I "C:\Program Files (x86)\Android\android-sdk\platforms\android-4\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 foll owing articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException 

我无法弄清楚错误是什么!

提前感谢大家!

Solutions Collecting From Web of "使用Maven构buildAndroid项目时出错"

好吧,我明白了:这是pom.xml的configuration问题:

 <plugin> <groupId>com.jayway.maven.plugins.android.generation2</groupId> ................... <configuration> <sdk> <platform>17</platform> </sdk> </configuration> ............ 

只要确保你在那里select正确的SDK版本。 match_parent值对于早期版本比Android SDK 1.6(我有一个<platform>4</platform> )是无效的。