1

数か月前に空き時間に Android プロジェクトを開始しました。友達が簡単にコラボレーションできるようにするために、maven を使用したいのですが、プロジェクトをビルドできません。

私のプロジェクトでは、ActionBarSherlock と Roboguice (およびこのコラボレーションを可能にする Roboguice Sherlock ライブラリ) を使用しています。私のpomを何時間もハックしようとした後、私はこれを持ってきました:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.github.armelbd</groupId>
<artifactId>my-places</artifactId>
<version>0.1-SNAPSHOT</version>
<name>MyPlaces</name>
<url>https://github.com/armelbd/my-places</url>

<issueManagement>
    <url>https://github.com/armelbd/my-places/issues</url>
    <system>GitHub Issues</system>
</issueManagement>

<licenses>
    <license>
        <name>Apache V2</name>
        <url>http://www.apache.org/licenses/LICENSE-2.0</url>
        <distribution>repo</distribution>
    </license>
</licenses>

<scm>
    <url>https://github.com/armelbd/my-places</url>
    <connection>scm:git:git://github.com/armelbd/my-places.git</connection>
    <developerConnection>scm:git:git@github.com:armelbd/my-places.git</developerConnection>
</scm>

<properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
</properties> 

<dependencies>
    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>android</artifactId>
        <scope>provided</scope>
        <version>4.0.1.2</version>
    </dependency>

    <!-- Dependency injection using Roboguice and Google Guice extensions -->
    <dependency>
        <groupId>org.roboguice</groupId>
        <artifactId>roboguice</artifactId>
        <version>2.0</version>
    </dependency>
    <dependency>
        <groupId>com.google.inject</groupId>
        <artifactId>guice</artifactId>
        <version>3.0</version>
        <classifier>no_aop</classifier>
    </dependency>
    <dependency>
        <groupId>com.google.inject.extensions</groupId>
        <artifactId>guice-multibindings</artifactId>
        <version>3.0</version>
    </dependency>
    <dependency>
        <groupId>com.google.inject.extensions</groupId>
        <artifactId>guice-assistedinject</artifactId>
        <version>3.0</version>
    </dependency>

    <!-- Action Bar sherlock -->
    <dependency>
        <groupId>com.actionbarsherlock</groupId>
        <artifactId>library</artifactId>
        <version>4.0.0</version>
        <type>apklib</type>
    </dependency>

    <!-- Let Roboguice and Sherlock work together -->
    <dependency>
        <groupId>com.github.rtyley</groupId>
        <artifactId>roboguice-sherlock</artifactId>
        <version>1.4</version>
    </dependency>
</dependencies>

<build>
    <finalName>${project.artifactId}</finalName>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
       <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <version>3.0.0</version>
            <extensions>true</extensions>
            <configuration>
                <sdk>
                    <platform>15</platform>
                </sdk>
            </configuration>
        </plugin>
    </plugins>
</build>

しかし、私はこれらのエラーが発生します:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building MyPlaces 0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ my-places ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/bourgona/Project/my-   places/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.5:compile (default-compile) @ my-places ---
[INFO] Compiling 18 source files to /Users/bourgona/Project/my-places/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /Users/bourgona/Project/my-  places/src/net/esial/myplaces/views/AddressBarFragment.java:[3,25] cannot find symbol
symbol  : class R
location: package net.esial.myplaces
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/views/AddressBarFragment.java:[8,33] package  com.actionbarsherlock.view does not exist
[ERROR] /Users/bourgona/Project/my-  places/src/net/esial/myplaces/views/AddressBarFragment.java:[9,33] package com.actionbarsherlock.view does not exist
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/views/AddressBarFragment.java:[22,7] cannot access   com.actionbarsherlock.app.SherlockFragment
class file for com.actionbarsherlock.app.SherlockFragment not found
public class AddressBarFragment extends RoboSherlockFragment {
[ERROR] /Users/bourgona/Project/my-  places/src/net/esial/myplaces/views/AddressBarFragment.java:[65,33] cannot find symbol
symbol  : class Menu
location: class net.esial.myplaces.views.AddressBarFragment
[ERROR] /Users/bourgona/Project/my-  places/src/net/esial/myplaces/views/AddressBarFragment.java:[65,44] cannot find symbol
symbol  : class MenuInflater
location: class net.esial.myplaces.views.AddressBarFragment
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/controllers/AddressAutoCompleteAdapter.java:[10,25] cannot find   symbol
symbol  : class R
location: package net.esial.myplaces
[ERROR] /Users/bourgona/Project/my-  places/src/net/esial/myplaces/views/PlacesActivity.java:[3,33] package   com.actionbarsherlock.view does not exist
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/views/PlacesActivity.java:[4,33] package  com.actionbarsherlock.view does not exist
[ERROR] /Users/bourgona/Project/my-places/src/net/esial/myplaces/views/PlacesActivity.java:[8,25] cannot find symbol
symbol  : class R
location: package net.esial.myplaces
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/views/PlacesActivity.java:[13,7] cannot access  com.actionbarsherlock.app.SherlockFragmentActivity
class file for com.actionbarsherlock.app.SherlockFragmentActivity not found
public class PlacesActivity extends RoboSherlockFragmentActivity {
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/views/PlacesActivity.java:[32,39] cannot find symbol
symbol  : class Menu
location: class net.esial.myplaces.views.PlacesActivity
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/views/AddressBarFragment.java:[32,2] cannot find symbol
symbol  : variable super
location: class net.esial.myplaces.views.AddressBarFragment
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/views/AddressBarFragment.java:[36,57] package R does not exist
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/views/AddressBarFragment.java:[36,10] cannot find symbol
symbol  : method getLayoutInflater(android.os.Bundle)
location: class net.esial.myplaces.views.AddressBarFragment
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/views/AddressBarFragment.java:[53,2] cannot find symbol
symbol  : variable this
location: class net.esial.myplaces.views.AddressBarFragment
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/views/AddressBarFragment.java:[30,1] method does not override or  implement a method from a supertype
[ERROR] /Users/bourgona/Project/my-  places/src/net/esial/myplaces/views/AddressBarFragment.java:[56,1] method does not override or  implement a method from a supertype
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/views/AddressBarFragment.java:[67,23] package R does not exist
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/views/AddressBarFragment.java:[64,1] method does not override or  implement a method from a supertype
[ERROR] /Users/bourgona/Project/my-  places/src/net/esial/myplaces/controllers/AddressAutoCompleteAdapter.java:[40,13] package R   does not exist
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/controllers/AddressAutoCompleteAdapter.java:[129,54] package R  does not exist
[ERROR] /Users/bourgona/Project/my-  places/src/net/esial/myplaces/views/PlacesActivity.java:[21,8] cannot find symbol
symbol  : variable super
location: class net.esial.myplaces.views.PlacesActivity
[ERROR] /Users/bourgona/Project/my-places/src/net/esial/myplaces/views/PlacesActivity.java:[22,24] package R does not exist
[ERROR] /Users/bourgona/Project/my-places/src/net/esial/myplaces/views/PlacesActivity.java:[25,42] cannot find symbol
symbol  : method getSupportFragmentManager()
location: class net.esial.myplaces.views.PlacesActivity
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/views/PlacesActivity.java:[27,27] cannot find symbol
symbol  : method add(net.esial.myplaces.views.AddressBarFragment,java.lang.String)
location: class android.support.v4.app.FragmentTransaction
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/views/PlacesActivity.java:[18,4] method does not override or  implement a method from a supertype
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/views/PlacesActivity.java:[34,8] cannot find symbol
symbol  : class MenuInflater
location: class net.esial.myplaces.views.PlacesActivity
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/views/PlacesActivity.java:[34,32] cannot find symbol
symbol  : method getSupportMenuInflater()
location: class net.esial.myplaces.views.PlacesActivity
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/views/PlacesActivity.java:[35,26] package R does not exist
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/views/PlacesActivity.java:[31,4] method does not override or   implement a method from a supertype
[INFO] 31 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.914s
[INFO] Finished at: Sun Jun 03 19:54:15 PDT 2012
[INFO] Final Memory: 12M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5:compile  (default-compile) on project my-places: Compilation failure: Compilation failure:
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/views/AddressBarFragment.java:[3,25] cannot find symbol
[ERROR] symbol  : class R
[ERROR] location: package net.esial.myplaces
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/views/AddressBarFragment.java:[8,33] package com.actionbarsherlock.view does not exist
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/views/AddressBarFragment.java:[9,33] package  com.actionbarsherlock.view does not exist
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/views/AddressBarFragment.java:[22,7] cannot access  com.actionbarsherlock.app.SherlockFragment
[ERROR] class file for com.actionbarsherlock.app.SherlockFragment not found
[ERROR] public class AddressBarFragment extends RoboSherlockFragment {
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/views/AddressBarFragment.java:[65,33] cannot find symbol
[ERROR] symbol  : class Menu
[ERROR] location: class net.esial.myplaces.views.AddressBarFragment
[ERROR] /Users/bourgona/Project/my-places/src/net/esial/myplaces/views/AddressBarFragment.java:[65,44] cannot find symbol
[ERROR] symbol  : class MenuInflater
[ERROR] location: class net.esial.myplaces.views.AddressBarFragment
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/controllers/AddressAutoCompleteAdapter.java:[10,25] cannot find  symbol
[ERROR] symbol  : class R
[ERROR] location: package net.esial.myplaces
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/views/PlacesActivity.java:[3,33] package  com.actionbarsherlock.view does not exist
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/views/PlacesActivity.java:[4,33] package  com.actionbarsherlock.view does not exist
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/views/PlacesActivity.java:[8,25] cannot find symbol
[ERROR] symbol  : class R
[ERROR] location: package net.esial.myplaces
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/views/PlacesActivity.java:[13,7] cannot access com.actionbarsherlock.app.SherlockFragmentActivity
[ERROR] class file for com.actionbarsherlock.app.SherlockFragmentActivity not found
[ERROR] public class PlacesActivity extends RoboSherlockFragmentActivity {
[ERROR] /Users/bourgona/Project/my-places/src/net/esial/myplaces/views/PlacesActivity.java:[32,39] cannot find symbol
[ERROR] symbol  : class Menu
[ERROR] location: class net.esial.myplaces.views.PlacesActivity
[ERROR] /Users/bourgona/Project/my-places/src/net/esial/myplaces/views/AddressBarFragment.java:[32,2] cannot find symbol
[ERROR] symbol  : variable super
[ERROR] location: class net.esial.myplaces.views.AddressBarFragment
[ERROR] /Users/bourgona/Project/my-places/src/net/esial/myplaces/views/AddressBarFragment.java:[36,57] package R does not exist
[ERROR] /Users/bourgona/Project/my-places/src/net/esial/myplaces/views/AddressBarFragment.java:[36,10] cannot find symbol
[ERROR] symbol  : method getLayoutInflater(android.os.Bundle)
[ERROR] location: class net.esial.myplaces.views.AddressBarFragment
[ERROR] /Users/bourgona/Project/my-places/src/net/esial/myplaces/views/AddressBarFragment.java:[53,2] cannot find symbol
[ERROR] symbol  : variable this
[ERROR] location: class net.esial.myplaces.views.AddressBarFragment
[ERROR] /Users/bourgona/Project/my-places/src/net/esial/myplaces/views/AddressBarFragment.java:[30,1] method does not override or  implement a method from a supertype
[ERROR] /Users/bourgona/Project/my-  places/src/net/esial/myplaces/views/AddressBarFragment.java:[56,1] method does not override or  implement a method from a supertype
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/views/AddressBarFragment.java:[67,23] package R does not exist
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/views/AddressBarFragment.java:[64,1] method does not override or  implement a method from a supertype
[ERROR] /Users/bourgona/Project/my-places/src/net/esial/myplaces/controllers/AddressAutoCompleteAdapter.java:[40,13] package R does not exist
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/controllers/AddressAutoCompleteAdapter.java:[129,54] package R does not exist
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/views/PlacesActivity.java:[21,8] cannot find symbol
[ERROR] symbol  : variable super
[ERROR] location: class net.esial.myplaces.views.PlacesActivity
[ERROR] /Users/bourgona/Project/my-places/src/net/esial/myplaces/views/PlacesActivity.java:[22,24] package R does not exist
[ERROR] /Users/bourgona/Project/my-places/src/net/esial/myplaces/views/PlacesActivity.java:[25,42] cannot find symbol
[ERROR] symbol  : method getSupportFragmentManager()
[ERROR] location: class net.esial.myplaces.views.PlacesActivity
[ERROR] /Users/bourgona/Project/my-places/src/net/esial/myplaces/views/PlacesActivity.java:[27,27] cannot find symbol
[ERROR] symbol  : method add(net.esial.myplaces.views.AddressBarFragment,java.lang.String)
[ERROR] location: class android.support.v4.app.FragmentTransaction
[ERROR] /Users/bourgona/Project/my-places/src/net/esial/myplaces/views/PlacesActivity.java:[18,4] method does not override or implement a method from a supertype
[ERROR] /Users/bourgona/Project/my-places/src/net/esial/myplaces/views/PlacesActivity.java:[34,8] cannot find symbol
[ERROR] symbol  : class MenuInflater
[ERROR] location: class net.esial.myplaces.views.PlacesActivity
[ERROR] /Users/bourgona/Project/my-places/src/net/esial/myplaces/views/PlacesActivity.java:[34,32] cannot find symbol
[ERROR] symbol  : method getSupportMenuInflater()
[ERROR] location: class net.esial.myplaces.views.PlacesActivity
[ERROR] /Users/bourgona/Project/my- places/src/net/esial/myplaces/views/PlacesActivity.java:[35,26] package R does not exist
[ERROR] /Users/bourgona/Project/my-places/src/net/esial/myplaces/views/PlacesActivity.java:[31,4] method does not override or implement a method from a supertype
[ERROR] -> [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/MojoFailureException

構成の何が問題になっていますか?

アップデート

追加した後、<packaging>apk</packaging>次のエラーが発生します。

[INFO] UNEXPECTED TOP-LEVEL EXCEPTION:
[INFO] java.lang.IllegalArgumentException: already added: Lcom/google/inject/AbstractModule;
[INFO]  at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
[INFO]  at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
[INFO]  at com.android.dx.command.dexer.Main.processClass(Main.java:486)
[INFO]  at com.android.dx.command.dexer.Main.processFileBytes(Main.java:455)
[INFO]  at com.android.dx.command.dexer.Main.access$400(Main.java:67)
[INFO]  at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:394)
[INFO]  at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
[INFO]  at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
[INFO]  at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
[INFO]  at com.android.dx.command.dexer.Main.processOne(Main.java:418)
[INFO]  at com.android.dx.command.dexer.Main.processAllFiles(Main.java:329)
[INFO]  at com.android.dx.command.dexer.Main.run(Main.java:206)
[INFO]  at com.android.dx.command.dexer.Main.main(Main.java:174)
[INFO]  at com.android.dx.command.Main.main(Main.java:95)
[INFO] 1 error; aborting
4

1 に答える 1

3

yorkwの助けを借りて、私はついにmavenを使用してプロジェクトをコンパイルできるようになりました。エラーは、already added: Lcom/google/inject/AbstractModuleguice-no_aopへの複数の依存によるものでした。

最初のroboguice2.0はguice-no_aopに依存しているので、この部分を削除します:

<dependency>
    <groupId>com.google.inject</groupId>
    <artifactId>guice</artifactId>
    <version>3.0</version>
    <classifier>no_aop</classifier>
</dependency> 

さらに、guice-multibindingsとguice-assistedinjectもguice-no_aopに依存していますが、まったく同じバージョンではありません。この質問で同様の問題が議論されたので、これをguice-multibindingsとguice-assistedinjectの依存関係に追加しました。

<exclusions>
    <exclusion>
        <groupId>com.google.inject</groupId>
        <artifactId>guice</artifactId>
    </exclusion>
</exclusions>

記録のために私の最後のpomは:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.armelbd</groupId>
<artifactId>my-places</artifactId>
<version>0.1-SNAPSHOT</version>
<name>MyPlaces</name>
<packaging>apk</packaging>
<url>https://github.com/armelbd/my-places</url>

<issueManagement>
    <url>https://github.com/armelbd/my-places/issues</url>
    <system>GitHub Issues</system>
</issueManagement>

<licenses>
    <license>
        <name>Apache V2</name>
        <url>http://www.apache.org/licenses/LICENSE-2.0</url>
        <distribution>repo</distribution>
    </license>
</licenses>

<scm>
    <url>https://github.com/armelbd/my-places</url>
    <connection>scm:git:git://github.com/armelbd/my-places.git</connection>
    <developerConnection>scm:git:git@github.com:armelbd/my-places.git</developerConnection>
</scm>

<properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
</properties> 

<dependencies>
    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>android</artifactId>
        <scope>provided</scope>
        <version>4.0.1.2</version>
    </dependency>

    <!-- Dependency injection using Roboguice and Google Guice extensions -->
    <dependency>
        <groupId>org.roboguice</groupId>
        <artifactId>roboguice</artifactId>
        <version>2.0</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>com.google.inject.extensions</groupId>
        <artifactId>guice-multibindings</artifactId>
        <version>3.0</version>
        <exclusions>
            <exclusion>
                <groupId>com.google.inject</groupId>
                <artifactId>guice</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>com.google.inject.extensions</groupId>
        <artifactId>guice-assistedinject</artifactId>
        <version>3.0</version>
        <exclusions>
            <exclusion>
                <groupId>com.google.inject</groupId>
                <artifactId>guice</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <!-- Action Bar sherlock -->
    <dependency>
        <groupId>com.actionbarsherlock</groupId>
        <artifactId>library</artifactId>
        <version>4.0.0</version>
        <type>apklib</type>
    </dependency>

    <!-- Let Roboguice and Sherlock work together -->
    <dependency>
        <groupId>com.github.rtyley</groupId>
        <artifactId>roboguice-sherlock</artifactId>
        <version>1.4</version>
    </dependency>
</dependencies>

<build>
    <finalName>${project.artifactId}</finalName>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
       <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <version>3.0.0</version>
            <extensions>true</extensions>
            <configuration>
                <sdk>
                    <platform>15</platform>
                </sdk>
            </configuration>
        </plugin>
    </plugins>
</build>

于 2012-06-04T06:35:00.940 に答える