Android Maven 编译失败



我已经为此苦苦挣扎了几个小时了......我有一个 maven Android lib 项目,编译它失败并显示以下调试输出:

[DEBUG] Configuring mojo org.apache.maven.plugins:maven-compiler-plugin:2.4:compile from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-compiler-plugin:2.4, parent: sun.misc.Launcher$AppClassLoader@77cde100]
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-compiler-plugin:2.4:compile' with basic configurator -->
[DEBUG]   (f) basedir = D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - Camera
[DEBUG]   (f) buildDirectory = D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - Cameratarget
[DEBUG]   (f) classpathElements = [D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - Cameratargetclasses, C:UsersTacB0sS.m2repositorycomnuartsoftwarenu-art-module-manager.0.1nu-art-module-manager-0.0.1.jar, C:UsersTacB0sS.m2repositorycomnuartsoftwarenu-art-exception-handling.0.1nu-art-exception-handling-0.0.1.jar, C:UsersTacB0sS.m2repositorycomnuartsoftwarenu-art-reflection.0.1nu-art-reflection-0.0.1.jar, C:UsersTacB0sS.m2repositorycomnuartsoftwarenu-art-core.0.1nu-art-core-0.0.1.jar, C:UsersTacB0sS.m2repositorycomnuartsoftwarenu-art-tools.0.1nu-art-tools-0.0.1.jar, C:UsersTacB0sS.m2repositoryorgjdomjdom1.1jdom-1.1.jar, C:UsersTacB0sS.m2repositorycomnuartsoftwarerexml.0.1rexml-0.0.1.jar, C:UsersTacB0sS.m2repositorycomnuartsoftwarecyborgcyborg.0.1cyborg-0.0.1.jar, C:UsersTacB0sS.m2repositorycomandroidframeworkandroid-intermediate-package.0.1android-intermediate-package-0.0.1.jar, C:UsersTacB0sS.m2repositorycomgoogleandroidandroid3.2_r1android-3.2_r1.jar]
[DEBUG]   (f) compileSourceRoots = [D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - Camerasrcmainjava, D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - Cameratargetgenerated-sourcesextracted-dependenciessrcmainjava, D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - Cameratargetgenerated-sourcesr, D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - Cameratargetgenerated-sourcesaidl]
[DEBUG]   (f) compilerId = javac
[DEBUG]   (f) debug = true
[DEBUG]   (f) encoding = UTF-8
[DEBUG]   (f) failOnError = true
[DEBUG]   (f) fork = false
[DEBUG]   (f) generatedSourcesDirectory = D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - Cameratargetgenerated-sourcesannotations
[DEBUG]   (f) optimize = false
[DEBUG]   (f) outputDirectory = D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - Cameratargetclasses
[DEBUG]   (f) outputFileName = cyborg-module-camera-0.0.1
[DEBUG]   (f) projectArtifact = com.nu.art.software.cyborg:cyborg-module-camera:apklib:0.0.1
[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@201d592a
[DEBUG]   (f) showDeprecation = false
[DEBUG]   (f) showWarnings = false
[DEBUG]   (f) source = 1.6
[DEBUG]   (f) staleMillis = 0
[DEBUG]   (f) target = 1.6
[DEBUG]   (f) verbose = false
[DEBUG] -- end configuration --
[DEBUG] Using compiler 'javac'.
[DEBUG] Source directories: [D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - Camerasrcmainjava
 D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - Cameratargetgenerated-sourcesr
 D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - Cameratargetgenerated-sourcesaidl]
[DEBUG] Classpath: [D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - Cameratargetclasses
 C:UsersTacB0sS.m2repositorycomnuartsoftwarenu-art-module-manager.0.1nu-art-module-manager-0.0.1.jar
 C:UsersTacB0sS.m2repositorycomnuartsoftwarenu-art-exception-handling.0.1nu-art-exception-handling-0.0.1.jar
 C:UsersTacB0sS.m2repositorycomnuartsoftwarenu-art-reflection.0.1nu-art-reflection-0.0.1.jar
 C:UsersTacB0sS.m2repositorycomnuartsoftwarenu-art-core.0.1nu-art-core-0.0.1.jar
 C:UsersTacB0sS.m2repositorycomnuartsoftwarenu-art-tools.0.1nu-art-tools-0.0.1.jar
 C:UsersTacB0sS.m2repositoryorgjdomjdom1.1jdom-1.1.jar
 C:UsersTacB0sS.m2repositorycomnuartsoftwarerexml.0.1rexml-0.0.1.jar
 C:UsersTacB0sS.m2repositorycomnuartsoftwarecyborgcyborg.0.1cyborg-0.0.1.jar
 C:UsersTacB0sS.m2repositorycomandroidframeworkandroid-intermediate-package.0.1android-intermediate-package-0.0.1.jar
 C:UsersTacB0sS.m2repositorycomgoogleandroidandroid3.2_r1android-3.2_r1.jar]
[DEBUG] Output directory: D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - Cameratargetclasses
[DEBUG] Classpath:
[DEBUG]  D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - Cameratargetclasses
[DEBUG]  C:UsersTacB0sS.m2repositorycomnuartsoftwarenu-art-module-manager.0.1nu-art-module-manager-0.0.1.jar
[DEBUG]  C:UsersTacB0sS.m2repositorycomnuartsoftwarenu-art-exception-handling.0.1nu-art-exception-handling-0.0.1.jar
[DEBUG]  C:UsersTacB0sS.m2repositorycomnuartsoftwarenu-art-reflection.0.1nu-art-reflection-0.0.1.jar
[DEBUG]  C:UsersTacB0sS.m2repositorycomnuartsoftwarenu-art-core.0.1nu-art-core-0.0.1.jar
[DEBUG]  C:UsersTacB0sS.m2repositorycomnuartsoftwarenu-art-tools.0.1nu-art-tools-0.0.1.jar
[DEBUG]  C:UsersTacB0sS.m2repositoryorgjdomjdom1.1jdom-1.1.jar
[DEBUG]  C:UsersTacB0sS.m2repositorycomnuartsoftwarerexml.0.1rexml-0.0.1.jar
[DEBUG]  C:UsersTacB0sS.m2repositorycomnuartsoftwarecyborgcyborg.0.1cyborg-0.0.1.jar
[DEBUG]  C:UsersTacB0sS.m2repositorycomandroidframeworkandroid-intermediate-package.0.1android-intermediate-package-0.0.1.jar
[DEBUG]  C:UsersTacB0sS.m2repositorycomgoogleandroidandroid3.2_r1android-3.2_r1.jar
[DEBUG] Source roots:
[DEBUG]  D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - Camerasrcmainjava
[DEBUG]  D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - Cameratargetgenerated-sourcesextracted-dependenciessrcmainjava
[DEBUG]  D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - Cameratargetgenerated-sourcesr
[DEBUG]  D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - Cameratargetgenerated-sourcesaidl
[DEBUG] Command line options:
[DEBUG] -d D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - Cameratargetclasses -classpath D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - Cameratargetclasses;C:UsersTacB0sS.m2repositorycomnuartsoftwarenu-art-module-manager.0.1nu-art-module-manager-0.0.1.jar;C:UsersTacB0sS.m2repositorycomnuartsoftwarenu-art-exception-handling.0.1nu-art-exception-handling-0.0.1.jar;C:UsersTacB0sS.m2repositorycomnuartsoftwarenu-art-reflection.0.1nu-art-reflection-0.0.1.jar;C:UsersTacB0sS.m2repositorycomnuartsoftwarenu-art-core.0.1nu-art-core-0.0.1.jar;C:UsersTacB0sS.m2repositorycomnuartsoftwarenu-art-tools.0.1nu-art-tools-0.0.1.jar;C:UsersTacB0sS.m2repositoryorgjdomjdom1.1jdom-1.1.jar;C:UsersTacB0sS.m2repositorycomnuartsoftwarerexml.0.1rexml-0.0.1.jar;C:UsersTacB0sS.m2repositorycomnuartsoftwarecyborgcyborg.0.1cyborg-0.0.1.jar;C:UsersTacB0sS.m2repositorycomandroidframeworkandroid-intermediate-package.0.1android-intermediate-package-0.0.1.jar;C:UsersTacB0sS.m2repositorycomgoogleandroidandroid3.2_r1android-3.2_r1.jar; -sourcepath D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - Camerasrcmainjava;D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - Cameratargetgenerated-sourcesr;D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - Cameratargetgenerated-sourcesaidl; D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - CamerasrcmainjavacomnuartsoftwarecyborgmodulescameracoreCameraLayer.java D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - CamerasrcmainjavacomnuartsoftwarecyborgmodulescameracoreCameraModule.java D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - CamerasrcmainjavacomnuartsoftwarecyborgmodulescameracoreCameraException.java -s D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - Cameratargetgenerated-sourcesannotations -g -nowarn -target 1.6 -source 1.6 -encoding UTF-8
[INFO] Compiling 3 source files to D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - Cameratargetclasses
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - CamerasrcmainjavacomnuartsoftwarecyborgmodulescameracoreCameraLayer.java:[79,80] cannot find symbol
symbol  : method getRotation()
location: class android.view.Display
[ERROR] D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - CamerasrcmainjavacomnuartsoftwarecyborgmodulescameracoreCameraModule.java:[50,23] cannot find symbol
symbol  : method getNumberOfCameras()
location: class android.hardware.Camera
[ERROR] D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - CamerasrcmainjavacomnuartsoftwarecyborgmodulescameracoreCameraModule.java:[66,26] cannot find symbol
symbol  : class CameraInfo
location: class android.hardware.Camera
[ERROR] D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - CamerasrcmainjavacomnuartsoftwarecyborgmodulescameracoreCameraModule.java:[66,78] cannot find symbol
symbol  : class CameraInfo
location: class android.hardware.Camera
[ERROR] D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - CamerasrcmainjavacomnuartsoftwarecyborgmodulescameracoreCameraModule.java:[88,19] open() in android.hardware.Camera cannot be applied to (int)
[ERROR] D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - CamerasrcmainjavacomnuartsoftwarecyborgmodulescameracoreCameraModule.java:[109,26] cannot find symbol
symbol  : class CameraInfo
location: class android.hardware.Camera
[ERROR] D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - CamerasrcmainjavacomnuartsoftwarecyborgmodulescameracoreCameraModule.java:[109,78] cannot find symbol
symbol  : class CameraInfo
location: class android.hardware.Camera
[ERROR] D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - CamerasrcmainjavacomnuartsoftwarecyborgmodulescameracoreCameraModule.java:[124,8] cannot find symbol
symbol  : method setDisplayOrientation(int)
location: class android.hardware.Camera
[INFO] 8 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

请注意,类路径变量之一是:C:\Users\TacB0sS.m2\repository\com\google\android\android\3.2_r1\android-3.2_r1.jar

我已经对此进行了双重和三重检查,我确定这些方法和类在上面的 jar 中,在 Eclipse 中,我在标准构建路径中使用相同的 jar,并且编译得很好,浏览它显示了包含的对象和方法。

我错过了什么?

更新:

一些有效的pom:

<properties>
    <owner>Adam Zehavi</owner>
    <android.version>3.2_r1</android.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <android.sdk>13</android.sdk>
    <company.name>Nu-Art Software</company.name>
    <nickname>TacB0sS</nickname>
    <android.emulator.name>emulator1</android.emulator.name>
</properties>
...
...
<dependencies>
    <dependency>
        <groupId>com.nu.art.software.cyborg</groupId>
        <artifactId>cyborg</artifactId>
        <version>0.0.1</version>
        <type>apklib</type>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.nu.art.software.cyborg</groupId>
        <artifactId>cyborg</artifactId>
        <version>0.0.1</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>android</artifactId>
        <version>3.2_r1</version>
        <scope>provided</scope>
    </dependency>
</dependencies>
...
...
<plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.4</version>
    <executions>
        <execution>
            <id>default-testCompile</id>
            <phase>test-compile</phase>
            <goals>
                <goal>testCompile</goal>
            </goals>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </execution>
        <execution>
            <id>default-compile</id>
            <phase>compile</phase>
            <goals>
                <goal>compile</goal>
            </goals>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </execution>
    </executions>
    <configuration>
        <source>1.6</source>
        <target>1.6</target>
    </configuration>
</plugin>

我认为问题出在安卓插件中的 sdk 级别错误

        <plugin>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <version>3.1.1</version>
            <configuration>
                <androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
                <assetsDirectory>${project.basedir}/assets</assetsDirectory>
                <resourceDirectory>${project.basedir}/res</resourceDirectory>                    
                <sdk>
                    <platform>13</platform> <!-- or ${android.sdk} in your case -->
                </sdk>
                <undeployBeforeDeploy>true</undeployBeforeDeploy>
            </configuration>
            <extensions>true</extensions>
        </plugin>

首先,错误消息表明您的依赖项不正确,因为您缺少所需的类(库)。

[ERROR] D:DevelopmentJavaProjectsFrameworksCyborgCyborg Module - CamerasrcmainjavacomnuartsoftwarecyborgmodulescameracoreCameraLayer.java:[79,80] cannot find symbol
symbol  : method getRotation()
location: class android.view.Display

问题是你从哪里得到你正在使用的jar(C:\Users\TacB0sS.m2\repository\com\google\android\android\3.2_r1\android-3.2_r1.jar)。如果我只是在找到一个罐子后通过谷歌搜索,但这个罐子不包含给定的类......此外,似乎有一些关于问题的提示(见问题)。

此外,我会建议不要在 Maven 中定义公约已经涵盖的内容

<plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.4</version>
    <executions>
        <execution>
            <id>default-testCompile</id>
            <phase>test-compile</phase>
            <goals>
                <goal>testCompile</goal>
            </goals>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </execution>
        <execution>
            <id>default-compile</id>
            <phase>compile</phase>
            <goals>
                <goal>compile</goal>
            </goals>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </execution>
    </executions>
    <configuration>
        <source>1.6</source>
        <target>1.6</target>
    </configuration>
</plugin>

以上可以简化为(小心使用最新版本的maven-编译器插件当前:2.5.1)。

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.5.1</version>
    <configuration>
        <source>1.6</source>
        <target>1.6</target>
    </configuration>
</plugin>

相关内容

  • 没有找到相关文章

最新更新