Maven使用谷歌地图库项目在Android项目中编译问题

时间:2013-10-23 13:51:04

标签: android maven

我正在尝试使用库项目的android项目。我已经创建了apklib并成功完成了mvn install:install-file命令。构建失败,出现编译错误。错误日志可以在下面看到,这表明我是否正确引用了谷歌地图库项目。

MapActivity.java:[320,51] cannot find symbol
symbol:   variable CameraUpdateFactory

无法引用com.google.android.gms.maps中的所有类。 pom.xml如下所示

<dependencies>
    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>android</artifactId>
        <version>${android.version}</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>com.google.android.support</groupId>
        <artifactId>support-v4</artifactId>
        <version>4</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>com.octo.android.robospice</groupId>
        <artifactId>robospice</artifactId>
        <version>${robospice.version}</version>
    </dependency>

    <dependency>
        <groupId>com.octo.android.robospice</groupId>
        <artifactId>robospice-spring-android</artifactId>
        <version>${robospice.spring.android.version}</version>
    </dependency>

    <dependency>
        <groupId>com.octo.android.robospice</groupId>
        <artifactId>robospice-ormlite</artifactId>
        <version>${robospice-ormlite.version}</version>
    </dependency>

    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-asl</artifactId>
        <version>${spring.android.jackson.version}</version>
    </dependency>

    <dependency>
        <groupId>com.j256.ormlite</groupId>
        <artifactId>ormlite-android</artifactId>
        <version>${ormlite.android.version}</version>
    </dependency>

    <dependency>
        <groupId>com.google.android.gms</groupId>
        <artifactId>google-play-services</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <type>apklib</type>
    </dependency>

    <dependency>
        <groupId>com.actionbarrefresh.lib</groupId>
        <artifactId>refresh-lib</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <type>apklib</type>
    </dependency>

</dependencies>

此外,无法引用android-support-v4库中的类。我已使用mvn install命令在本地存储库中添加了该库,但仍然会引发错误。它说无法找到SupportMapFragment。

任何关于此的指示都会有所帮助。

2 个答案:

答案 0 :(得分:1)

只需添加地图相关性。

    <dependency>
        <groupId>com.google.android.maps</groupId>
        <artifactId>maps</artifactId>
        <version>7_r1</version>
        <scope>provided</scope>
        <optional>true</optional>
    </dependency>

然后转到https://github.com/mosabua/maven-android-sdk-deployer

mvn install -P 4.3 lib。到你的m2。

答案 1 :(得分:0)

我已经能够通过maven build解决这个问题。

问题是apklib实际上不包含库项目的libs文件夹中的jar。 libs文件夹中的jar需要通过maven install命令安装,然后除了apklib之外,pom.xml也应该依赖于它。所以,我从谷歌地图的libs文件夹安装了jar文件,并在pom.xml中添加了依赖项,并且它运行良好。

我首先应该检查apklib是否包含来自libs文件夹的jar文件,但无论如何最终这个问题得到了解决。