Android Maven Project in Eclipse with apklib

2019-09-17 07:01发布

问题:

I am trying to add google play services to existing android maven project using jar and apklib. The project does compile using mvn clean install, but in Eclipse i am getting this error:

Error: No resource found that matches the given name (at 'value' with value '@integer/google_play_services_version'). AndroidManifest.xml /pruebas-bundle-android line 51 Android AAPT Problem

I am new with maven, so i don´t know what could cause this. I have searched for information on the error but have not found anything that could let me solve it. I am using maven 3.2.2 and m2e 1.4. This is my pom.xml

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.pruebas.pruebas</groupId>
  <artifactId>pruebas-bundle-android</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>apk</packaging>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <dependencies>
    <dependency>
      <groupId>android</groupId>
      <artifactId>android</artifactId>
      <version>4.4.2_r3</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>android.support</groupId>
      <artifactId>compatibility-v4</artifactId>
      <version>20.0.0</version>
    </dependency>
    <dependency>
        <groupId>com.google.android.gms</groupId>
        <artifactId>google-play-services</artifactId>
        <version>19.0.0</version>
        <type>apklib</type>
    </dependency>
    <dependency>
        <groupId>com.google.android.gms</groupId>
        <artifactId>google-play-services</artifactId>
        <version>19.0.0</version>
        <type>jar</type>
    </dependency>
    <dependency>
      <groupId>urbanairship</groupId>
      <artifactId>urbanairship-lib</artifactId>
      <version>4.0.3</version>
    </dependency>
    <dependency>
      <groupId>com.crittercism</groupId>
      <artifactId>crittercism-android-agent</artifactId>
      <version>LATEST</version>
    </dependency>
  </dependencies>
  <repositories>
    <repository>
      <id>local-repository</id>
      <url>file:${basedir}/local-repository</url>
    </repository>
  </repositories>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <groupId>com.jayway.maven.plugins.android.generation2</groupId>
        <artifactId>android-maven-plugin</artifactId>
        <version>3.9.0-rc.3</version>
        <extensions>true</extensions>
        <configuration>
          <sdk>
            <platform>19</platform>
          </sdk>
          <manifest>
            <debuggable>false</debuggable>
          </manifest>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

The problem seems to be due to the apklib. In Eclipse, i can see all my dependencies jar in Maven dependencies, but i don´t know how to make available the google play services apklib in Eclipse. I would appreciate any help with this.

回答1:

In order to compile a project with an Android Library (APKLIB) dependency in Eclipse you need to have m2e-android installed and a "Mavenised" copy of the Android Library source code checked-out into your local Eclipse workspace.

When I say "Mavenised" I mean that the Android Library project should have a POM with coordinates (group ID, version, etc.) that match the apklib dependency in you application POM.