android-maven-plugin - 如何设置apkMetaIncludes?

时间:2013-01-22 19:30:13

标签: android android-maven-plugin

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

  

要打包到apk中的其他META-INF资源的模式。   APK构建器会过滤这些资源,但不会将其包含在内   apk。这导致依赖的依赖库的不良行为   这些资源,例如服务发现不起作用。通过   指定此模式,android插件将这些资源添加到   最后的apk。该模式与META-INF相关,即必须使用:

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

META-INF文件夹位于src文件夹

<?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>

最后,我的APK没有服务文件夹!

1 个答案:

答案 0 :(得分:2)

这在javadoc中实际上是错误的。我会修好它。在此期间,这应该工作

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

当然,我也欢迎反馈/确认它有效,并可能提供更新文档的拉取请求..