3

私は今、これに何時間も苦労しています... 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:\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 = 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:\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] ------------------------------------------------------------------------

クラスパス変数の 1 つが C:\Users\TacB0sS.m2\repository\com\google\android\android\3.2_r1\android-3.2_r1.jar であることに注意してください。

私はこれを2倍と3倍にチェックしました。これらのメソッドとクラスは上記のjarファイルにあると確信しています.Eclipseでは、標準のビルドパスで同じjarファイルを使用しており、問題なくコンパイルされます.また、参照するとオブジェクトが表示されます.とメソッドが含まれています。

私は何が欠けていますか?

アップデート:

効果的なポンのいくつか:

<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>
4

2 に答える 2

3

問題は android-maven-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>
于 2012-09-24T11:58:45.900 に答える
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) をどこで入手するかです。jarが見つかった後にGoogleで検索しただけで、この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-compiler-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>
于 2012-09-24T09:42:32.357 に答える