所以我在使用 maven 的 android 插件时遇到了编译错误。
[DEBUG] ANDROID-040-000: Executed command: Commandline = /bin/sh -c cd /Users/adrian/Development/projects/GogoDroid && /Users/adrian/Development/bin/android-sdk-macosx/platform-tools/aapt package -f -M /Users/adrian/Development/projects/GogoDroid/AndroidManifest.xml -S /Users/adrian/Development/projects/GogoDroid/res -S /Users/adrian/Development/projects/GogoDroid/target/unpack/apklibs/org.holoeverywhere_library_apklib_1.4.0/res -S /Users/adrian/Development/projects/GogoDroid/target/unpack/apklibs/com.actionbarsherlock_actionbarsherlock_apklib_4.2.0/res -S /Users/adrian/Development/projects/GogoDroid/target/unpack/apklibs/com.facebook.android_Facebook_apklib_3.0.0/res --auto-add-overlay -A /Users/adrian/Development/projects/GogoDroid/target/generated-sources/combined-assets/assets -I /Users/adrian/Development/bin/android-sdk-macosx/platforms/android-16/android.jar -F /Users/adrian/Development/projects/GogoDroid/target/gogodroid.ap_, Result = 1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 58.008s
[INFO] Finished at: Thu Dec 20 02:47:51 PST 2012
[INFO] Final Memory: 18M/123M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.4.1:apk (default-apk) on project gogodroid: MojoExecutionException: ANDROID-040-001: Could not execute: Command = /bin/sh -c cd /Users/adrian/Development/projects/GogoDroid && /Users/adrian/Development/bin/android-sdk-macosx/platform-tools/aapt package -f -M /Users/adrian/Development/projects/GogoDroid/AndroidManifest.xml -S /Users/adrian/Development/projects/GogoDroid/res -S /Users/adrian/Development/projects/GogoDroid/target/unpack/apklibs/org.holoeverywhere_library_apklib_1.4.0/res -S /Users/adrian/Development/projects/GogoDroid/target/unpack/apklibs/com.actionbarsherlock_actionbarsherlock_apklib_4.2.0/res -S /Users/adrian/Development/projects/GogoDroid/target/unpack/apklibs/com.facebook.android_Facebook_apklib_3.0.0/res --auto-add-overlay -A /Users/adrian/Development/projects/GogoDroid/target/generated-sources/combined-assets/assets -I /Users/adrian/Development/bin/android-sdk-macosx/platforms/android-16/android.jar -F /Users/adrian/Development/projects/GogoDroid/target/gogodroid.ap_, Result = 1 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.4.1:apk (default-apk) on project gogodroid:
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
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: org.apache.maven.plugin.MojoExecutionException:
at com.jayway.maven.plugins.android.phase09package.ApkMojo.generateIntermediateApk(ApkMojo.java:1103)
at com.jayway.maven.plugins.android.phase09package.ApkMojo.execute(ApkMojo.java:287)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
Caused by: com.jayway.maven.plugins.android.ExecutionException: ANDROID-040-001: Could not execute: Command = /bin/sh -c cd /Users/adrian/Development/projects/GogoDroid && /Users/adrian/Development/bin/android-sdk-macosx/platform-tools/aapt package -f -M /Users/adrian/Development/projects/GogoDroid/AndroidManifest.xml -S /Users/adrian/Development/projects/GogoDroid/res -S /Users/adrian/Development/projects/GogoDroid/target/unpack/apklibs/org.holoeverywhere_library_apklib_1.4.0/res -S /Users/adrian/Development/projects/GogoDroid/target/unpack/apklibs/com.actionbarsherlock_actionbarsherlock_apklib_4.2.0/res -S /Users/adrian/Development/projects/GogoDroid/target/unpack/apklibs/com.facebook.android_Facebook_apklib_3.0.0/res --auto-add-overlay -A /Users/adrian/Development/projects/GogoDroid/target/generated-sources/combined-assets/assets -I /Users/adrian/Development/bin/android-sdk-macosx/platforms/android-16/android.jar -F /Users/adrian/Development/projects/GogoDroid/target/gogodroid.ap_, Result = 1
at com.jayway.maven.plugins.android.CommandExecutor$Factory$1.executeCommand(CommandExecutor.java:339)
at com.jayway.maven.plugins.android.phase09package.ApkMojo.generateIntermediateApk(ApkMojo.java:1099)
... 22 more
[ERROR]
[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
➜ GogoDroid git:(feature/build_script) ✗ mvn -v
Apache Maven 3.0.4 (r1232337; 2012-01-17 00:44:56-0800)
Maven home: /usr/local/Cellar/maven/3.0.4/libexec
Java version: 1.6.0_29, vendor: Apple Inc.
Java home: /Library/Java/JavaVirtualMachines/1.6.0_29-b11-402.jdk/Contents/Home
Default locale: en_US, platform encoding: MacRoman
OS name: "mac os x", version: "10.7.5", arch: "x86_64", family: "mac"
有谁知道发生了什么?我注意到的唯一另一件奇怪的事情是,在构建实际失败之前似乎有很多奇怪的资源调试消息。
(实际失败前的消息)
INFO] /Users/adrian/Development/projects/GogoDroid/res/drawable/tab_trips_selector.xml:14: error: Error: No resource found that matches the given name (at 'drawable' with value '@drawable/tab_trip_ic_sel').
[INFO] /Users/adrian/Development/projects/GogoDroid/res/drawable/tab_trips_selector.xml:15: error: Error: No resource found that matches the given name (at 'drawable' with value '@drawable/tab_trip_ic_sel').
[INFO] /Users/adrian/Development/projects/GogoDroid/res/drawable/tab_trips_selector.xml:18: error: Error: No resource found that matches the given name (at 'drawable' with value '@drawable/tab_trip_ic').
[INFO] /Users/adrian/Development/projects/GogoDroid/res/drawable/tab_trips_selector.xml:19: error: Error: No resource found that matches the given name (at 'drawable' with value '@drawable/tab_trip_ic_sel').
[INFO] /Users/adrian/Development/projects/GogoDroid/res/menu/feed_menu.xml:4: error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/refresh_ic').
[INFO] /Users/adrian/Development/projects/GogoDroid/res/menu/me_menu.xml:4: error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/ab_invite_ic').
[INFO] /Users/adrian/Development/projects/GogoDroid/res/menu/moment_menu.xml:4: error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/ab_info_ic').
提前感谢您的帮助。
更新 1 - 这是 pom 供参考,我刚刚将插件更新到 3.5.0,但仍然看到相同的错误。它仍然与资源有关。看起来像
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>apk</packaging>
<!-- Omitted Group Info -->
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.holoeverywhere</groupId>
<artifactId>library</artifactId>
<version>1.4.0</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>1.5.2</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.roboguice</groupId>
<artifactId>roboguice</artifactId>
<version>2.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>net.hockeyapp.android</groupId>
<artifactId>HockeySDK</artifactId>
<version>2.2.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.apache.amber</groupId>
<artifactId>amber-oauth2-client</artifactId>
<version>0.22-incubating</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>com.actionbarsherlock</groupId>
<artifactId>actionbarsherlock</artifactId>
<version>4.2.0</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>com.github.kevinsawicki</groupId>
<artifactId>urbanairship-lib</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>com.google.android.maps</groupId>
<artifactId>maps</artifactId>
<version>16_r3</version>
<scope>provided</scope>
</dependency>
<!-- <dependency>
<groupId>android.support</groupId>
<artifactId>compatibility-v4</artifactId>
<version>11</version>
</dependency> -->
<dependency>
<groupId>com.androidquery</groupId>
<artifactId>aquery</artifactId>
<version>0.22.10</version>
</dependency>
<dependency>
<groupId>com.commonsware.cwac.adapter</groupId>
<artifactId>AdapterWrapper</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.commonsware.cwac.endless</groupId>
<artifactId>EndlessAdapter</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.facebook.android</groupId>
<artifactId>Facebook</artifactId>
<version>3.0.0</version>
<exclusions>
<exclusion>
<groupId>android.support</groupId>
<artifactId>compatibility-v4</artifactId>
</exclusion>
</exclusions>
<type>apklib</type>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<sourceDirectory>src</sourceDirectory>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.5.0</version>
<extensions>true</extensions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
<sdk>
<path>/Users/adrian/Development/bin/android-sdk-macosx</path>
<platform>4.1.2</platform>
</sdk>
<extractDuplicates>true</extractDuplicates>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
</plugin>
</plugins>
</build>
</project>
更新 2 - 看起来这是一个特定于 Android Maven 的问题,抱怨我的 9.patch 图像不是真正的 9.patch 图像。Eclipse 和 Intellij 可以很好地编译 apks……有人有办法让 maven android 表现得像 Eclipse 和 Intellij 吗?