MojoExecutionException:的Maven与Android [英] MojoExecutionException: Maven with Android

查看:1564
本文介绍了MojoExecutionException:的Maven与Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Android的工作室与Maven 3.1.1,并在其与MojoExecutionException崩溃包的目标。我已经readed很多帖子,但我不能得到解决。

[错误]错误发生源的时候。

  org.apache.maven.plugin.MojoExecutionException:
    在com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.generateR(GenerateSourcesMojo.java:593)
    在com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.execute(GenerateSourcesMojo.java:216)
    在org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
    在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    在org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    在org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    在org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    在org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    在org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
    在org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
    在org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
    在org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
    在org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
    在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)
    在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    在java.lang.reflect.Method.invoke(Method.java:606)
    在有机codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    在有机codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    在有机codehaus.plexus.classworlds.launcher.Launcher.mainWithExit code(Launcher.java:415)
    在有机codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
    在有机codehaus.classworlds.Launcher.main(Launcher.java:46)
    在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)
    在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    在java.lang.reflect.Method.invoke(Method.java:606)
    在com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
致:com.jayway.maven.plugins.android.ExecutionException:Android为040-001:无法执行:命令= CMD.EXE / X / CC:\ Users \用户hvalls \应用程序数据\本地\机器人\ android-工作室\ SDK \集结工具\ 19.0.3 \ aapt.exe包-f --no-紧缩-IC:\用户\ hvalls \应用程序数据\本地\机器人\机器人工作室\ SDK \平台\ Android为19 \机器人的.jar -MC:\ Users \用户hvalls \桌面\我的应用程序内\ AndroidManifest.xml中-SC:\ Users \用户hvalls \桌面\我的应用程序内\ RES -AC:\ Users \用户hvalls \桌面\我的应用程序内\目标\产生-源\联合资产\资产-m -jc:\ Users \用户hvalls \桌面\我的应用程序内\目标\产生-源\ r  - 输出 - 文本符号C:\​​ Users \用户hvalls \桌面\我 - 应用程序\目标--auto-附加叠加,结果= -1073741819
    在com.jayway.maven.plugins.android.CommandExecutor$Factory$DefaultCommandExecutor.executeCommand(CommandExecutor.java:246)
    在com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.generateR(GenerateSourcesMojo.java:589)
    ... 28更多
[信息]  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - - -------------------------
[信息]构建失败
[信息]  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - - -------------------------
[信息]总时间:16.665s
[信息]收于:周二03月25日22时32分34秒CET 2014年
[信息]最后的内存:19M / 184M
[信息]  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - - -------------------------
[错误]未能执行目标com.jayway.maven.plugins.android.generation2:Android的Maven的插件:3.8.2:产生-源项目(默认生成-源)我的应用程序内:MojoExecutionException:ANDROID-040 -001:无法执行:命令= CMD.EXE / X / CC:\ Users \用户hvalls \应用程序数据\本地\机器人\机器人工作室\ SDK \集结工具\ 19.0.3 \ aapt.exe包-f --no-紧缩-IC:\用户\ hvalls \应用程序数据\本地\机器人\机器人工作室\ SDK \平台\ Android为19 \的android.jar -MC:\ Users \用户hvalls \桌面\我的应用程序内\ AndroidManifest。 XML -SC:\ Users \用户hvalls \桌面\我的应用程序内\ RES -AC:\ Users \用户hvalls \桌面\我的应用程序内\目标\产生-源\联合资产\资产-m -jc:\用户\ hvalls \桌面\我的应用程序内\目标\产生-源\ r  - 输出 - 文本符号C:\​​ Users \用户hvalls \桌面\我的应用程序内\目标--auto-附加叠加,结果= -1073741819  - &GT ; [说明1]
[错误]
[错误]要查看错误的完整的堆栈跟踪,重新运行Maven和-e开关。
[错误]使用-x开关来实现完整的调试日志记录重新运行Maven。
[错误]
[错误]有关错误和可能的解决方案,请阅读以下文章:
[错误] [说明1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

流程完成出口code 1
 

的pom.xml

 < XML版本=1.0编码=UTF-8&GT?;
<项目的xmlns:XSI =htt​​p://www.w3.org/2001/XMLSchema-instance
    的xmlns =htt​​p://maven.apache.org/POM/4.0.0
    XSI:的schemaLocation =htt​​p://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    < modelVersion> 4.0.0< / modelVersion>
    <的groupId> com.android.app< /的groupId>
    < artifactId的>我-的应用程序和LT; / artifactId的>
    <版> 1.0-SNAPSHOT< /版本>
    <包装> APK< /包装>
    <名称>我的应用程序内和LT; /名称>

    <性状>
        < project.build.sourceEncoding> UTF-8< /project.build.sourceEncoding>
        < platform.version> 4.1.1.4
        < /platform.version>
        < android.plugin.version> 3.8.2< /android.plugin.version>
    < /性状>

    <依赖>
        <! -  Android的注释 - >
        <依赖>
            <的groupId> com.google code.androidannotations< /的groupId>
            < artifactId的> androidannotations-API< / artifactId的>
            <版> 2.7.1< /版本>
        < /依赖性>
        <依赖>
            <的groupId> com.google code.androidannotations< /的groupId>
            < artifactId的> androidannotations< / artifactId的>
            <版> 2.7.1< /版本>
            <范围>提供与LT; /范围>
        < /依赖性>

        <依赖>
            <的groupId> com.google.android< /的groupId>
            < artifactId的>的android< / artifactId的>
            <版> $ {platform.version}< /版本>
            <范围>提供与LT; /范围>
        < /依赖性>
    < /依赖性>
    <建立>
        < finalName> $ {project.artifactId}< / finalName>
        < pluginManagement>
            <插件>
                <插件>
                    <的groupId> com.jayway.maven.plugins.android.generation2< /的groupId>
                    < artifactId的> Android的行家,插件和LT; / artifactId的>
                    <版> $ {android.plugin.version}< /版本>
                    <扩展>真< /扩展>
                < /插件>
            < /插件>
        < / pluginManagement>
        <插件>
            <插件>
                <的groupId> com.jayway.maven.plugins.android.generation2< /的groupId>
                < artifactId的> Android的行家,插件和LT; / artifactId的>
                <版> 3.8.2< /版本>
                <结构>
                    < SDK>
                        <平台> 19< /平台>
                    < / SDK>
                < /结构>
            < /插件>
        < /插件>
    < /编译>
< /项目>
 

解决方案

此问题是有点棘手,但可以解决的!

首先,当你得到像你得到一个错误信息,你应该尝试运行的Maven的说,它无法运行,因为Maven的下载依存关系后,并建立code等。Maven的它自身运行的命令一开始的命令,让您的apk。在你的情况是:

  C:\ Users \用户hvalls \应用程序数据\本地\机器人\机器人工作室\ SDK \集结工具\ 19.0.3 \ aapt.exe包-f --no-紧缩-IC:\ Users \用户hvalls \应用程序数据\本地\机器人\机器人工作室\ SDK \平台\ Android为19 \的android.jar -MC:\ Users \用户hvalls \桌面\我的应用程序内\ AndroidManifest.xml中-SC:\用户\ hvalls \桌面\我的应用程序内\ RES -AC:\ Users \用户hvalls \桌面\我的应用程序内\目标\产生-源\联合资产\资产-m -jc:\ Users \用户hvalls \桌面\我 - 应用程序\目标\产生-源\ r  - 输出 - 文本符号C:\​​ Users \用户hvalls \桌面\我的应用程序内\目标--auto-附加覆盖
 

所以,当您运行此,它会给你的dx.bat工具的真正错误输出。刚修好您在输出中看到的,然后重新运行MVN的错误。

在我来说,我得到这个错误,因为在我的资源文件夹中的形象之一,是不是PNG文件虽然扩展PNG。当我固定的文件类型,它的工作。

I'm using Android Studio with Maven 3.1.1 and in the package goal it crashes with a MojoExecutionException. I have readed lot of posts but I can't get the solution.

[ERROR] Error when generating sources.

org.apache.maven.plugin.MojoExecutionException: 
    at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.generateR(GenerateSourcesMojo.java:593)
    at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.execute(GenerateSourcesMojo.java:216)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    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:317)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:46)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: com.jayway.maven.plugins.android.ExecutionException: ANDROID-040-001: Could not execute: Command = cmd.exe /X /C "C:\Users\hvalls\AppData\Local\Android\android-studio\sdk\build-tools\19.0.3\aapt.exe package -f --no-crunch -I C:\Users\hvalls\AppData\Local\Android\android-studio\sdk\platforms\android-19\android.jar -M C:\Users\hvalls\Desktop\my-app\AndroidManifest.xml -S C:\Users\hvalls\Desktop\my-app\res -A C:\Users\hvalls\Desktop\my-app\target\generated-sources\combined-assets\assets -m -J C:\Users\hvalls\Desktop\my-app\target\generated-sources\r --output-text-symbols C:\Users\hvalls\Desktop\my-app\target --auto-add-overlay", Result = -1073741819
    at com.jayway.maven.plugins.android.CommandExecutor$Factory$DefaultCommandExecutor.executeCommand(CommandExecutor.java:246)
    at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.generateR(GenerateSourcesMojo.java:589)
    ... 28 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.665s
[INFO] Finished at: Tue Mar 25 22:32:34 CET 2014
[INFO] Final Memory: 19M/184M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.8.2:generate-sources (default-generate-sources) on project my-app: MojoExecutionException: ANDROID-040-001: Could not execute: Command = cmd.exe /X /C "C:\Users\hvalls\AppData\Local\Android\android-studio\sdk\build-tools\19.0.3\aapt.exe package -f --no-crunch -I C:\Users\hvalls\AppData\Local\Android\android-studio\sdk\platforms\android-19\android.jar -M C:\Users\hvalls\Desktop\my-app\AndroidManifest.xml -S C:\Users\hvalls\Desktop\my-app\res -A C:\Users\hvalls\Desktop\my-app\target\generated-sources\combined-assets\assets -m -J C:\Users\hvalls\Desktop\my-app\target\generated-sources\r --output-text-symbols C:\Users\hvalls\Desktop\my-app\target --auto-add-overlay", Result = -1073741819 -> [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

Process finished with exit code 1

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://maven.apache.org/POM/4.0.0"
    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.android.app</groupId>
    <artifactId>my-app</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>apk</packaging>
    <name>my-app</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <platform.version>4.1.1.4
        </platform.version>
        <android.plugin.version>3.8.2</android.plugin.version>
    </properties>

    <dependencies>
        <!--Android Annotations-->
        <dependency>
            <groupId>com.googlecode.androidannotations</groupId>
            <artifactId>androidannotations-api</artifactId>
            <version>2.7.1</version>
        </dependency>
        <dependency>
            <groupId>com.googlecode.androidannotations</groupId>
            <artifactId>androidannotations</artifactId>
            <version>2.7.1</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>${platform.version}</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>${project.artifactId}</finalName>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                    <artifactId>android-maven-plugin</artifactId>
                    <version>${android.plugin.version}</version>
                    <extensions>true</extensions>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <version>3.8.2</version>
                <configuration>
                    <sdk>
                        <platform>19</platform>
                    </sdk>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

解决方案

This issue was a little tricky, but can be solved!

First, when you get an error message like the one you got, you should try to run the command which Maven said it failed to run, because after maven downloads dependencies and builds code etc.. Maven it self runs the initial command to make your apk. At your case it is:

C:\Users\hvalls\AppData\Local\Android\android-studio\sdk\build-tools\19.0.3\aapt.exe package -f --no-crunch -I C:\Users\hvalls\AppData\Local\Android\android-studio\sdk\platforms\android-19\android.jar -M C:\Users\hvalls\Desktop\my-app\AndroidManifest.xml -S C:\Users\hvalls\Desktop\my-app\res -A C:\Users\hvalls\Desktop\my-app\target\generated-sources\combined-assets\assets -m -J C:\Users\hvalls\Desktop\my-app\target\generated-sources\r --output-text-symbols C:\Users\hvalls\Desktop\my-app\target --auto-add-overlay

So when you run this it will give you the real error output of the dx.bat tool. Just fix the errors that you see at output and rerun the mvn.

In my case I got this error because one of the image under my res folder is not a png file although the extension is png. After I fixed the file type it worked.

这篇关于MojoExecutionException:的Maven与Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆