2012-09-21 319 views
3

我一直在苦苦掙扎與此幾個小時......我有一個Maven的Android LIB項目,編譯它失敗,出現以下調試輸出:的Android Maven的編譯失敗

[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: [email protected]] 
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-compiler-plugin:2.4:compile' with basic configurator --> 
[DEBUG] (f) basedir = D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera 
[DEBUG] (f) buildDirectory = D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\target 
[DEBUG] (f) classpathElements = [D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\target\classes, C:\Users\TacB0sS\.m2\repository\com\nu\art\software\nu-art-module-manager\0.0.1\nu-art-module-manager-0.0.1.jar, C:\Users\TacB0sS\.m2\repository\com\nu\art\software\nu-art-exception-handling\0.0.1\nu-art-exception-handling-0.0.1.jar, C:\Users\TacB0sS\.m2\repository\com\nu\art\software\nu-art-reflection\0.0.1\nu-art-reflection-0.0.1.jar, C:\Users\TacB0sS\.m2\repository\com\nu\art\software\nu-art-core\0.0.1\nu-art-core-0.0.1.jar, C:\Users\TacB0sS\.m2\repository\com\nu\art\software\nu-art-tools\0.0.1\nu-art-tools-0.0.1.jar, C:\Users\TacB0sS\.m2\repository\org\jdom\jdom\1.1\jdom-1.1.jar, C:\Users\TacB0sS\.m2\repository\com\nu\art\software\rexml\0.0.1\rexml-0.0.1.jar, C:\Users\TacB0sS\.m2\repository\com\nu\art\software\cyborg\cyborg\0.0.1\cyborg-0.0.1.jar, C:\Users\TacB0sS\.m2\repository\com\android\framework\android-intermediate-package\0.0.1\android-intermediate-package-0.0.1.jar, C:\Users\TacB0sS\.m2\repository\com\google\android\android\3.2_r1\android-3.2_r1.jar] 
[DEBUG] (f) compileSourceRoots = [D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\src\main\java, D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\target\generated-sources\extracted-dependencies\src\main\java, D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\target\generated-sources\r, D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\target\generated-sources\aidl] 
[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:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\target\generated-sources\annotations 
[DEBUG] (f) optimize = false 
[DEBUG] (f) outputDirectory = D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\target\classes 
[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 = [email protected] 
[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:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\src\main\java 
D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\target\generated-sources\r 
D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\target\generated-sources\aidl] 
[DEBUG] Classpath: [D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\target\classes 
C:\Users\TacB0sS\.m2\repository\com\nu\art\software\nu-art-module-manager\0.0.1\nu-art-module-manager-0.0.1.jar 
C:\Users\TacB0sS\.m2\repository\com\nu\art\software\nu-art-exception-handling\0.0.1\nu-art-exception-handling-0.0.1.jar 
C:\Users\TacB0sS\.m2\repository\com\nu\art\software\nu-art-reflection\0.0.1\nu-art-reflection-0.0.1.jar 
C:\Users\TacB0sS\.m2\repository\com\nu\art\software\nu-art-core\0.0.1\nu-art-core-0.0.1.jar 
C:\Users\TacB0sS\.m2\repository\com\nu\art\software\nu-art-tools\0.0.1\nu-art-tools-0.0.1.jar 
C:\Users\TacB0sS\.m2\repository\org\jdom\jdom\1.1\jdom-1.1.jar 
C:\Users\TacB0sS\.m2\repository\com\nu\art\software\rexml\0.0.1\rexml-0.0.1.jar 
C:\Users\TacB0sS\.m2\repository\com\nu\art\software\cyborg\cyborg\0.0.1\cyborg-0.0.1.jar 
C:\Users\TacB0sS\.m2\repository\com\android\framework\android-intermediate-package\0.0.1\android-intermediate-package-0.0.1.jar 
C:\Users\TacB0sS\.m2\repository\com\google\android\android\3.2_r1\android-3.2_r1.jar] 
[DEBUG] Output directory: D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\target\classes 
[DEBUG] Classpath: 
[DEBUG] D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\target\classes 
[DEBUG] C:\Users\TacB0sS\.m2\repository\com\nu\art\software\nu-art-module-manager\0.0.1\nu-art-module-manager-0.0.1.jar 
[DEBUG] C:\Users\TacB0sS\.m2\repository\com\nu\art\software\nu-art-exception-handling\0.0.1\nu-art-exception-handling-0.0.1.jar 
[DEBUG] C:\Users\TacB0sS\.m2\repository\com\nu\art\software\nu-art-reflection\0.0.1\nu-art-reflection-0.0.1.jar 
[DEBUG] C:\Users\TacB0sS\.m2\repository\com\nu\art\software\nu-art-core\0.0.1\nu-art-core-0.0.1.jar 
[DEBUG] C:\Users\TacB0sS\.m2\repository\com\nu\art\software\nu-art-tools\0.0.1\nu-art-tools-0.0.1.jar 
[DEBUG] C:\Users\TacB0sS\.m2\repository\org\jdom\jdom\1.1\jdom-1.1.jar 
[DEBUG] C:\Users\TacB0sS\.m2\repository\com\nu\art\software\rexml\0.0.1\rexml-0.0.1.jar 
[DEBUG] C:\Users\TacB0sS\.m2\repository\com\nu\art\software\cyborg\cyborg\0.0.1\cyborg-0.0.1.jar 
[DEBUG] C:\Users\TacB0sS\.m2\repository\com\android\framework\android-intermediate-package\0.0.1\android-intermediate-package-0.0.1.jar 
[DEBUG] C:\Users\TacB0sS\.m2\repository\com\google\android\android\3.2_r1\android-3.2_r1.jar 
[DEBUG] Source roots: 
[DEBUG] D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\src\main\java 
[DEBUG] D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\target\generated-sources\extracted-dependencies\src\main\java 
[DEBUG] D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\target\generated-sources\r 
[DEBUG] D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\target\generated-sources\aidl 
[DEBUG] Command line options: 
[DEBUG] -d D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\target\classes -classpath D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\target\classes;C:\Users\TacB0sS\.m2\repository\com\nu\art\software\nu-art-module-manager\0.0.1\nu-art-module-manager-0.0.1.jar;C:\Users\TacB0sS\.m2\repository\com\nu\art\software\nu-art-exception-handling\0.0.1\nu-art-exception-handling-0.0.1.jar;C:\Users\TacB0sS\.m2\repository\com\nu\art\software\nu-art-reflection\0.0.1\nu-art-reflection-0.0.1.jar;C:\Users\TacB0sS\.m2\repository\com\nu\art\software\nu-art-core\0.0.1\nu-art-core-0.0.1.jar;C:\Users\TacB0sS\.m2\repository\com\nu\art\software\nu-art-tools\0.0.1\nu-art-tools-0.0.1.jar;C:\Users\TacB0sS\.m2\repository\org\jdom\jdom\1.1\jdom-1.1.jar;C:\Users\TacB0sS\.m2\repository\com\nu\art\software\rexml\0.0.1\rexml-0.0.1.jar;C:\Users\TacB0sS\.m2\repository\com\nu\art\software\cyborg\cyborg\0.0.1\cyborg-0.0.1.jar;C:\Users\TacB0sS\.m2\repository\com\android\framework\android-intermediate-package\0.0.1\android-intermediate-package-0.0.1.jar;C:\Users\TacB0sS\.m2\repository\com\google\android\android\3.2_r1\android-3.2_r1.jar; -sourcepath D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\src\main\java;D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\target\generated-sources\r;D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\target\generated-sources\aidl; D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\src\main\java\com\nu\art\software\cyborg\modules\camera\core\CameraLayer.java D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\src\main\java\com\nu\art\software\cyborg\modules\camera\core\CameraModule.java D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\src\main\java\com\nu\art\software\cyborg\modules\camera\core\CameraException.java -s D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\target\generated-sources\annotations -g -nowarn -target 1.6 -source 1.6 -encoding UTF-8 
[INFO] Compiling 3 source files to D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\target\classes 
[INFO] ------------------------------------------------------------- 
[ERROR] COMPILATION ERROR : 
[INFO] ------------------------------------------------------------- 
[ERROR] D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\src\main\java\com\nu\art\software\cyborg\modules\camera\core\CameraLayer.java:[79,80] cannot find symbol 
symbol : method getRotation() 
location: class android.view.Display 
[ERROR] D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\src\main\java\com\nu\art\software\cyborg\modules\camera\core\CameraModule.java:[50,23] cannot find symbol 
symbol : method getNumberOfCameras() 
location: class android.hardware.Camera 
[ERROR] D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\src\main\java\com\nu\art\software\cyborg\modules\camera\core\CameraModule.java:[66,26] cannot find symbol 
symbol : class CameraInfo 
location: class android.hardware.Camera 
[ERROR] D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\src\main\java\com\nu\art\software\cyborg\modules\camera\core\CameraModule.java:[66,78] cannot find symbol 
symbol : class CameraInfo 
location: class android.hardware.Camera 
[ERROR] D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\src\main\java\com\nu\art\software\cyborg\modules\camera\core\CameraModule.java:[88,19] open() in android.hardware.Camera cannot be applied to (int) 
[ERROR] D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\src\main\java\com\nu\art\software\cyborg\modules\camera\core\CameraModule.java:[109,26] cannot find symbol 
symbol : class CameraInfo 
location: class android.hardware.Camera 
[ERROR] D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\src\main\java\com\nu\art\software\cyborg\modules\camera\core\CameraModule.java:[109,78] cannot find symbol 
symbol : class CameraInfo 
location: class android.hardware.Camera 
[ERROR] D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\src\main\java\com\nu\art\software\cyborg\modules\camera\core\CameraModule.java:[124,8] cannot find symbol 
symbol : method setDisplayOrientation(int) 
location: class android.hardware.Camera 
[INFO] 8 errors 
[INFO] ------------------------------------------------------------- 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 

注意,一classpath變量是: C:\ Users \ TacB0sS.m2 \ repository \ com \ google \ android \ android \ 3.2_r1 \ android-3.2_r1.jar

我已經加倍和三重檢查過了,確定這些方法和類都在上面的jar中,在Eclipse中我使用了標準構建路徑中的相同jar,並且它編譯得很好,同時瀏覽它也顯示了對象和方法inclu DED。

我錯過了什麼?

UPDATE:

一些有效的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> 
+0

請提供您的POM –

+0

POM的結構是複雜的,但我會後的一些有效的POM的。 – TacB0sS

+1

它是你的庫項目的pom.xml還是主項目的pom.xml?如果可能,請附上完整的pom.xml。 – yorkw

回答

3

我認爲這個問題是在Android的Maven的插件錯誤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> 
+0

這讓我得到了正確的答案......我有一箇舊的配置文件,我應該刪除pom層次結構中的某個地方,android配置文件的空配置會導致錯誤。 – TacB0sS

0

首先,錯誤信息表明您的依賴關係是不正常的原因您缺少所需的類(庫)..

[ERROR] D:\Development\Java\Projects\Frameworks\Cyborg\Cyborg Module - Camera\src\main\java\com\nu\art\software\cyborg\modules\camera\core\CameraLayer.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)。如果我簡單地通過谷歌搜索後,它發現了一個罐子,但這個罐子不包含給定的類別....此外,似乎有一些提示problems(see issues).

此外,我會補充不要在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> 

上面可以簡化爲覆蓋(: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>