2

http://maven-android-plugin-m2site.googlecode.com/svn/apk-mojo.html#apkMetaIncludes

Pattern for additional META-INF resources to be packaged into the apk. The APK builder filters these resources and doesn't include them into the apk. This leads to bad behaviour of dependent libraries relying on these resources, for instance service discovery doesn't work. By specifying this pattern, the android plugin adds these resources to the final apk. The pattern is relative to META-INF, i.e. one must use:

<apkMetaIncludes>
    <metaInclude>services/**</metaInclude>
</apkMetaIncludes>

The META-INF folder is under src folder

<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>br.com.alpha9.teste</groupId>
    <artifactId>testemvn</artifactId>
    <version>1.0.0</version>
    <packaging>apk</packaging>
    <name>testemvn</name>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</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.5.0</version>
                <configuration>
                    <androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
                    <assetsDirectory>${project.basedir}/assets</assetsDirectory>
                    <resourceDirectory>${project.basedir}/res</resourceDirectory>
                    <nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory>
                    <sdk>
                        <path>/Applications/android-sdk-macosx</path>
                        <platform>13</platform>
                    </sdk>
                    <undeployBeforeDeploy>true</undeployBeforeDeploy>
                    <apkMetaIncludes>
                        <metaInclude>services/**</metaInclude>
                    </apkMetaIncludes>
                </configuration>
                <extensions>true</extensions>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>4.0.1.2</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</project>

At the end, my APK has no services folder!

Manfred Moser
  • 29,539
  • 13
  • 92
  • 123
CelinHC
  • 1,857
  • 2
  • 27
  • 36

1 Answers1

2

This is actually wrong in the javadoc. I will fix it. In the meantime this should work

<configuration>
  <apk>
    <metaIncludes>
      <metaInclude>services/**</metaInclude>
    </metaIncludes>
  </apk>
</configuration>

Of course I would also welcome feedback/confirmation that it works and potentially a pull request that updates the docs..

Manfred Moser
  • 29,539
  • 13
  • 92
  • 123
  • I just checked the code. There might be some more work required to get this right.. – Manfred Moser Feb 27 '13 at 06:20
  • should either of these configurations work in 3.5.3? (because neither is working for me ...) – Stevie May 14 '13 at 11:08
  • 1
    ok, so my particular problem is that it does copy META-INF entries from dependency jars but not from android library projects. – Stevie May 14 '13 at 14:06