0

我从 ant 切换到 maven 来构建 android 项目。但是我发现使用 android-maven 插件配置我以前的 ant 项目非常困难。在我将这个项目配置为与官方示例项目相同后,除了主项目下的源文件夹尚未编译外,一切正常。我已经检查了很多次 pom.xml,但是示例项目下的同一个 pom.xml 可以正常工作,但在我自己的项目中却不行。

我通过检查目标文件夹中的类文件夹发现没有编译 src。

这是我的 pom.xml:

http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 com.jayway.maven.plugins.android.generation2.samples.libraryprojects libraryprojects-parent 1.0.0-SNAPSHOT com.jayway.maven.plugins .android.generation2.samples.libraryprojects libraryprojects-mainapp apk 库项目 - 主应用程序

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

    <dependency>
        <groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>
        <artifactId>lib5</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <scope>system</scope>  
        <systemPath>${project.basedir}/libs/imageloader-core.jar</systemPath> 

    </dependency>

    <dependency>
        <groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>
        <artifactId>lib2</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <scope>system</scope>  
        <systemPath>${project.basedir}/libs/baidumapapi.jar</systemPath>  
    </dependency>


    <dependency>
        <groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>
        <artifactId>lib6</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <scope>system</scope>  
        <systemPath>${project.basedir}/libs/locSDK_3.3.jar
        </systemPath>  
    </dependency>

    <dependency>
        <groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>
        <artifactId>lib8</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <scope>system</scope>  
        <systemPath>${project.basedir}/libs/umeng_sdk.jar
        </systemPath>  
    </dependency>

    <dependency>
        <groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>
        <artifactId>androidv4</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <scope>system</scope>  
        <systemPath>${project.basedir}/libs/android-support-v4.jar
        </systemPath>  
    </dependency>

    <dependency>
        <groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>
        <artifactId>lib9</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <scope>system</scope>  
        <systemPath>${project.basedir}/libs/weibo.sdk.android.sso.jar
        </systemPath>  
    </dependency>
    <dependency>
        <groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>
        <artifactId>pulltorefresh</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <type>apklib</type>
    </dependency>

    <dependency>
        <groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>
        <artifactId>libraryprojects-lib1</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <type>apklib</type>
    </dependency>

    <dependency>
        <groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>
        <artifactId>libraryprojects-lib2</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <type>apklib</type>
    </dependency>
    <!--<dependency>-->
        <!--<groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>-->
        <!--<artifactId>libraryprojects-lib3</artifactId>-->
        <!--<version>1.0.0-SNAPSHOT</version>-->
        <!--<type>apklib</type>-->
    <!--</dependency>-->
    <dependency>
        <groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>
        <artifactId>libraryprojects-lib4</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <type>apklib</type>
    </dependency>
    <dependency>
        <groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>
        <artifactId>libraryprojects-lib5</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <type>apklib</type>
    </dependency>
    <!--<dependency>-->
        <!--<groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>-->
        <!--<artifactId>libraryprojects-lib7</artifactId>-->
        <!--<version>1.0.0-SNAPSHOT</version>-->
        <!--<type>apklib</type>-->
    <!--</dependency>-->
    <dependency>
        <groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>
        <artifactId>libraryprojects-lib8</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <type>apklib</type>
    </dependency>
    <dependency>
        <groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>
        <artifactId>slidingmenu</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <type>apklib</type>
    </dependency>
    <dependency>
        <groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>
        <artifactId>libraryprojects-lib10</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <type>apklib</type>
    </dependency>
    <dependency>
        <groupId>com.jayway.maven.plugins.android.generation2.samples.libraryprojects</groupId>
        <artifactId>actionbarsherlock</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <type>apklib</type>
    </dependency>
</dependencies>

<build>
    <finalName>${project.artifactId}</finalName>
    <sourceDirectory>${project.baseDir}</sourceDirectory>
    <plugins>
        <plugin>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <extensions>true</extensions>
        </plugin>
    </plugins>
</build>

4

1 回答 1

1

似乎是由于源目录层次结构不适合 maven 造成的。

对于普通的 android 项目,src 层次结构是src/com/a/b,但对于 maven 是 `src/main/java/com/a/b'。

于 2013-06-28T04:40:35.780 回答