1

我是 Maven 的新手,我几乎已经完成了 pom.xml 的编写,但是每次我向前一点时,我都会遇到另一个错误。这次这个错误看起来像这样:

  [INFO] ------------------------------------------------------------------------
[INFO] Building RecipeGrazer - App 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ NotepadAndroid ---
[INFO] Deleting /Users/username/Documents/notepad-pro/my-app-android/NotepadAndroid/target
[INFO] 
[INFO] --- android-maven-plugin:3.6.1:generate-sources (default-generate-sources) @ NotepadAndroid ---
[INFO] ANDROID-904-002: Found aidl files: Count = 1
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] Manifest merging disabled. Using project manifest only
[INFO] /Users/username/Desktop/sdk/build-tools/18.0.1/aapt [package, -m, -J, /Users/username/Documents/notepad-pro/my-app-android/NotepadAndroid/target/generated-sources/r, -M, /Users/username/Documents/notepad-pro/my-app-android/NotepadAndroid/AndroidManifest.xml, -S, /Users/username/Documents/notepad-pro/my-app-android/NotepadAndroid/res, --auto-add-overlay, -A, /Users/username/Documents/notepad-pro/my-app-android/NotepadAndroid/assets, -I, /Users/username/Desktop/sdk/platforms/android-10/android.jar]
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ NotepadAndroid ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/username/Documents/notepad-pro/my-app-android/NotepadAndroid/src/main/resources
[INFO] skip non existing resourceDirectory /Users/username/Documents/notepad-pro/my-app-android/NotepadAndroid/target/generated-sources/extracted-dependencies/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ NotepadAndroid ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 309 source files to /Users/username/Documents/notepad-pro/my-app-android/NotepadAndroid/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.899s
[INFO] Finished at: Thu Aug 22 12:25:43 CEST 2013
[INFO] Final Memory: 18M/367M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project NotepadAndroid: Fatal error compiling: invalid target release: 2.3.3 -> [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

有什么问题 ?我更改了 API,但仍然出现相同的错误。

这是我的 pom 的主要部分:

roperties>
        <environment>development</environment>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>2.3.3</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>support-v4</artifactId>
            <version>r7</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>20030203.000550</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.2.4</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>12.0.1</version>
        </dependency>
        <dependency>
            <groupId>com.google.inject</groupId>
            <artifactId>guice</artifactId>
            <version>2.0-no_aop</version>
        </dependency>
        <dependency>
            <groupId>com.google.http-client</groupId>
            <artifactId>google-http-client-android</artifactId>
            <version>1.16.0-rc</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpmime</artifactId>
            <version>4.2.5</version>
        </dependency>
        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java</artifactId>
            <version>2.4.1</version>
        </dependency>
        <dependency>
            <groupId>org.roboguice</groupId>
            <artifactId>roboguice</artifactId>
            <version>2.0</version>
        </dependency>
        <dependency>
            <groupId>oauth.signpost</groupId>
            <artifactId>signpost-commonshttp4</artifactId>
            <version>1.2.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.twitter4j</groupId>
            <artifactId>twitter4j-core</artifactId>
            <version>2.1.11</version>
        </dependency>

    </dependencies>

    <build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <source>2.3.3</source>
                    <target>2.3.3</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <version>3.6.1</version>
                <configuration>
                    <sdk>
                        <platform>10</platform>
                    </sdk>
                    <emulator>
                        <avd>22</avd>
                    </emulator>
                    <undeployBeforeDeploy>true</undeployBeforeDeploy>
                    <proguard>
                        <skip>false</skip>
                    </proguard>
                </configuration>
                <extensions>true</extensions>
            </plugin>
        </plugins>
    </build>
4

2 回答 2

1

由于构建在maven-compiler-plugin:compile目标上失败,很可能是这样的:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <encoding>UTF-8</encoding>
                <source>2.3.3</source>
                <target>2.3.3</target>
            </configuration>
        </plugin>

源版本和目标版本参数适用于Java版本,而不是Android 版本,即您应该使用以下内容:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <encoding>UTF-8</encoding>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>

我怀疑如果您使用-X参数运行构建(正如 Maven 本身所建议的那样),您将获得一些相关信息。

于 2013-08-22T13:39:21.023 回答
0

试试这个。它会对你有所帮助。

将此添加到 pom.xml 文件中

<build>
 <plugins>
   <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.6.0</version>
        <configuration>
            <encoding>UTF-8</encoding>
            <source>1.8</source>
            <target>1.8</target>
        </configuration>
    </plugin>
 </plugins>

您可以将 1.8 更改为您的 jdk 版本

在这之后

右键项目-->属性-->Java构建路径

在库标签中

选择JRE System library-->点击edit-->Workspace default JRE option--->jre--> edid-->Directory-->jdk

然后返回

这将帮助你

于 2017-01-13T05:22:21.607 回答