无法使用Maven-Android-Plugin构建android项目

时间:2013-01-09 11:37:58

标签: android maven maven-plugin

我只是想使用Maven-Android-Plugin构建我的android项目。但它给出了以下错误:

F:\Android\AsyncTaskSample>mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building AsyncTaskSample 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ asynctasksample ---
[INFO] Deleting F:\Android\AsyncTaskSample\target
[INFO]
[INFO] --- android-maven-plugin:3.5.0:generate-sources (default-generate-sources) @ asynctasksample ---
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] Manifest merging disabled. Using project manifest only
[INFO] E:\Nitin\Android-SDK\Android\android-sdk\platform-tools\aapt.exe [package, -m, -J, F:\Android\AsyncTaskSample\target\generated-sources\r, -M, F:\Android\AsyncTaskSample\AndroidManifest.xml, -S, F:\Android\AsyncTaskSample\res, --auto-add-overlay, -A, F:\Android\AsyncTaskSample\assets, -I, E:\Nitin\Android-SDK\Android\android-sdk\platforms\android-4\android.jar]
[INFO] F:\Android\AsyncTaskSample\res\values-v11\styles.xml:3: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Light'.
[ERROR] Error when generating sources.
org.apache.maven.plugin.MojoExecutionException:
        at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.generateR(GenerateSourcesMojo.java:468)
        at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.execute(GenerateSourcesMojo.java:193)
        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 "E:\Nitin\Android-SDK\Android\android-sdk\platform-tools\aapt.exe package -m -J F:\Android\AsyncTaskSample\target\generated-sources\r -M F:\Android\AsyncTaskSample\AndroidManifest.xml -S F:\Android\AsyncTaskSample\res --auto-add-overlay -A F:\Android\AsyncTaskSample\assets -I E:\Nitin\Android-SDK\Android\android-sdk\platforms\android-4\android.jar", Result = 1
        at com.jayway.maven.plugins.android.CommandExecutor$Factory$1.executeCommand(CommandExecutor.java:339)
        at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.generateR(GenerateSourcesMojo.java:464)
        ... 22 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.427s
[INFO] Finished at: Wed Jan 09 16:58:50 IST 2013
[INFO] Final Memory: 6M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.5.0:generate-sources (default-generate-sources) on project asynctasksample: MojoExecutionException: ANDROID-040-001: Could not execute: Command = cmd.exe /X /C "E:\Nitin\Android-SDK\Android\android-sdk\platform-tools\aapt.exe package -m -J F:\Android\AsyncTaskSample\target\generated-sources\r -M F:\Android\AsyncTaskSample\AndroidManifest.xml -S F:\Android\AsyncTaskSample\res --auto-add-overlay -A F:\Android\AsyncTaskSample\assets -I E:\Nitin\Android-SDK\Android\android-sdk\platforms\android-4\and
roid.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
F:\Android\AsyncTaskSample>

pom.xml内容如下:

<?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>
    <groupId>com.example</groupId>
    <artifactId>asynctasksample</artifactId>
    <version>1.0</version>
    <packaging>apk</packaging>
    <name>AsyncTaskSample</name>

    <dependencies>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>1.6_r2</version>
            <scope>provided</scope>
        </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>
                        <!-- platform or api level (api level 4 = platform 1.6)-->
                        <platform>4</platform>
                    </sdk>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

settings.xml文件内容@“C:\ Users \ rsahu.m2”如下:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
            http://maven.apache.org/xsd/settings-1.0.0.xsd">
        <pluginGroups>
            <pluginGroup>com.jayway.maven.plugins.android.generation2</pluginGroup>
        </pluginGroups>
        <profiles>
            <profile>
                <id>android</id>
                <properties>
                    <android.sdk.path>
                        E:\Nitin\Android-SDK\Android\android-sdk
                    </android.sdk.path>
                </properties>
            </profile>
        </profiles>
        <activeProfiles>
            <!--make the profile active all the time -->
            <activeProfile>android</activeProfile>
        </activeProfiles>
    </settings>

通过查看上面的文件内容,是否可以解决问题!请告诉我。感谢。

1 个答案:

答案 0 :(得分:4)

我注意到Maven输出中的这个错误

No resource found that matches the given name 'android:Theme.Holo.Light'

此外,您还在pom.xml

中将目标Android操作系统指定为1.6
<dependency>
    <groupId>com.google.android</groupId>
    <artifactId>android</artifactId>
    <version>1.6_r2</version>
    <scope>provided</scope>
</dependency>

您需要将主题更改为android:Theme.Light

或将依赖项中的目标Android版本更改为更高版本。 Holo仅在Android 4.0(16级)中可用